Date: Mon, 23 Oct 2006 18:02:09 -0400
Reply-To: Martin Mathis <martin.u.mathis@BANKOFAMERICA.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Martin Mathis <martin.u.mathis@BANKOFAMERICA.COM>
Subject: Re: do loop
Syntactically, the code below looks perfectly valid and error free. I'd
structure it differently for readability but oh well.
Where do you think you are going wrong and why?
I'm merely speculating:
a) Are you confident that all the expected variables are on
dataset "newdate" and are SAS date variables? AE_ONSET_DATE,
dateregistered, death etc.
Do they ever satisfy any of the criteria at all? You might want a catch-
all "else" or "else do" at the bottom that says ErrorMessage="No Error". Or
says "else delete;" in lieu of a conditional "output" statement should you
only want error obs in the ERROR dataset.
b)Are you asking whether you should be using a series of stand-alone IFs
without the ELSEs because you somehow want more than one possible
ErrorMessage per observation, if logically that can be the case with your
data?
Best,
MM
On Mon, 23 Oct 2006 16:53:21 -0400, Sigurd Hermansen <HERMANS1@WESTAT.COM>
wrote:
>Jessica:
>The only loop that I see is the SAS Data step implicit loop; that is,
>the SET statement as you have written it reads each row (obs) in dataset
>'newdate' in turn and executes the statements as conditioned by IF ELSE
>statements. The do; ...end; blocks include assignments of messages that
>execute together whenever an IF or ELSE condition holds.
>
>I see no reason why any of the IF - ELSE statements should be in
>separate Data steps. Perhaps you should post another message to SAS-L
>and tell us more about what you expect to happen and what is actually
>happening when you run your program.
>Sig
>
>-----Original Message-----
>From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu]
>On Behalf Of phillyj
>Sent: Monday, October 23, 2006 4:32 PM
>To: sas-l@uga.edu
>Subject: do loop
>
>
>Hello everyone. Can someone please take a look at my code below and let
>me know where I am going wrong? Perhaps i am misunderstanding the do
>loop and these should all be separate data steps? Thanks!
>
>Data ERROR;
>set newdate (where=(AE_ONSET_DATE ne .));
>
> IF year(AE_ONSET_DATE) < 2001 OR month(AE_ONSET_DATE)> 12 or
>day(AE_ONSET_DATE)>31 then
> do ; ErrorMessage='AE ONSET not within study boundries'; end;
>else IF AE_ONSET_DATE < dateregistered AND dateregistered NE . then do;
> ErrorMessage='AE ONSET is after date of randomization'; end;
>else IF AE_ONSET_DATE > AE_RESOLVED_DATE AND AE_RESOLVED_DATE NE . then
>do;
> ErrorMessage='AE ONSET is after AE RESOLVED'; end;
>else If AE_ONSET_DATE > death AND DEATH NE . then do;
> ErrorMessage='AE ONSET is after date of Death'; end; else If
>AE_ONSET_DATE < mindate AND mindate NE . then do;
> ErrorMessage='AE ONSET is before date of start therapy'; end;
>run;
|