Date: Tue, 18 Nov 2003 15:15:29 -0500
Reply-To: "Dasappan, Michael" <Michael_Dasappan@MEDCOHEALTH.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Dasappan, Michael" <Michael_Dasappan@MEDCOHEALTH.COM>
Subject: Re: Multiple %if statements
Content-Type: text/plain
Ron,
My code works, I am looking for help on stringing multiple %if.
Thanks
-----Original Message-----
From: Fehd, Ronald J. (PHPPO) [mailto:rjf2@cdc.gov]
Sent: Tuesday, November 18, 2003 3:09 PM
To: ___ SAS-L
Cc: Michael Dasappan
Subject: RE: Multiple %if statements
> From: Michael Dasappan [mailto:Michael_Dasappan@MEDCOHEALTH.COM]
> I have code that evaluates multiple criteria and I use %if
> statements like this
>
> %if (&groupid NE '' and &contractid NE '' and &carrid NE '')
> %then %do;
maybe you -think- you do
but the correct syntax for testing whether a macro variable is blank is
%if &groupid NE
and &contractid NE
and &carrid NE
%then %do;
note-1: parens unnecessary for a group of ands
note-2: mVars are not SAS character vars
they are always character strings
in this case the string is <null>
meaning no need for quotes
if you want to mnemonically show you are testing for null string: %if
"&groupid." NE "" which means the value of GroupId is a string of length
zero
> ....code here
>
> Question is if I have multiple %if that execute the same
> code, is there a way to string them together, something like
>
> %if (&groupid NE '' and &contractid NE '' and &carrid NE '') %else if;
> %if (&groupid NE '' and &contractid = '' and &carrid NE '') %else if;
> %if (&groupid NE '' and &contractid NE '' and &carrid = '') %then %do;
> ...code here
uh, how about a test senario?
the above sets of %if statements are mutually exclusive
Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov
By using your intelligence
you can sometimes make your problems twice as complicated.
-- Ashleigh Brilliant
... not to mention that it won't work
-----------------------------------------
This e-mail message and any attachments contain confidential information from Medco Health Solutions, Inc. If you are not the intended recipient, you are hereby notified that disclosure, printing, copying, distribution, or the taking of any action in reliance on the contents of this electronic information is strictly prohibited. If you have received this e-mail message in error, please immediately notify the sender by reply message and then delete the electronic message and any attachments.