Date: Tue, 4 Jan 2011 10:35:05 -0800
Reply-To: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject: Re: Love With SAS - My Vote for my favorite SAS Programming
Language "Feature"
In-Reply-To: <201101041729.p04Fui84007178@wasabi.cc.uga.edu>
Content-Type: text/plain; charset=utf-8
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Chang Chung
> Sent: Tuesday, January 04, 2011 9:30 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: Love With SAS - My Vote for my favorite SAS Programming
> Language "Feature"
>
> On Thu, 30 Dec 2010 19:49:37 -0500, Arthur Tabachneck
> <art297@ROGERS.COM>
> wrote:
>
> >From now until the New Year is usually a really quiet time for SAS-L,
> but
> >MMMMIIIIKKKKEEEE's post showed us that doesn't have to be the case.
> >
> >Thus, in an effort to keep the list from having a sad, lonely New
> Year's
> Eve,
> >I thought that one extra thread might provide the necessary stimulus.
> >
> >And, to get things going, my vote is for the ever increasing functions
> that
> >keep being added with each version.
> >
> >What's yours?
>
> I love the syntax of the (iterative) do statement, which is flexible
> without being fussy:
>
> DO index-variable = spec1, spec2, ..., specn;
> ...
> END;
>
> where spec# denotes:
> start <TO stop> <BY increment> <WHILE(exp)|UNTIL(exp)>
>
Chang,
I also like the flexibility of the DO loop control structure, but it can bite you if you don't understand that the specs separated by commas are independent. There has been more than one thread on SAS-L that dealt with this issue (although I can't find them at the moment). For example,
Data test;
Done = 0;
Do j = 1, 3, 5, 7 until(done);
If j > 1 then done=1;
Put j;
End;
Run;
In the above example, the until() clause only applies to the final comma-separated group (i.e. when j=7). This has confused even some seasoned SAS programmers.
Hope this is helpful,
Dan
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
|