Date: Fri, 27 Oct 2006 14:07:10 -0400
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: program efficiency problem
On Thu, 26 Oct 2006 04:52:08 -0400, Jim Groeneveld <jim2stat@YAHOO.CO.UK> wrote:
>Dear Jessica,
>
>Next to the other replies I would like to point you to the syntax errors
>that you could have solved by your own by looking at the log.
>1. You did not end the DO statement with a semicolon;
Actually, a block of code like
if V009=3 then do V009=3; end;
is *syntactically* OK, though probably unintentional. What you have is a
doubly trivial DO loop. It's trivial in that
1. It only iterates once.
2. There's no code within the loop, so it doesn't do anytjing other than
manage its index.
If you consider that the index variable assignment echoes the IF condition,
I suppose it's triply trivial.
>2. You can't use FIRST if your V009 isn't in the BY list.
> (I think you have to read about FIRST and LAST in your docs.)
>
>Next, if you have only one statement between DO; and END; you may as well
>omit DO; and END;
>
>Finally your first three IF statements are redundant as they do not change
>anything. Someone else already presented a better alternative for this.
>
>Regards - Jim.
>--
>Jim Groeneveld, Netherlands
>Statistician, SAS consultant
>home.hccnet.nl/jim.groeneveld
>
>On Wed, 25 Oct 2006 08:03:18 -0700, phillyj <jessica.donato@GMAIL.COM> wrote:
>
>>good morning. I am running into a brain freeze for the most efficient
>>way to program my desired output. Essentially I want to output only the
>>lowest value (1 vs 4) for each patient. (see program) I created v009
>>and keep in mind each patient can have more than one. Again, I want to
>>select only the lowest value for each patient. My first. keyword is
>>being read as a variable and saying it is unitialized. Certainly i am
>>using this incorrectly. Any suggestions would be appreciated.
>>Thanks--
>>
>> Data NewSurg;
>>set Surg;
>>by upn;
>>If v009=1 then do V009=1; end;
>>Else if V009=2 then do V009=2; end;
>>Else if V009=3 then do V009=3; end;
>>Else V009=99;
>>if First.V009 then output NewSurg; run;