Date: Fri, 1 Sep 2006 14:09:01 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: Using the IN operator in %IF statement
In-Reply-To: <8B5E9B95CC245C46A68BF4495A29A7EEB3C35A@chpdm-mail.chpdm.umbc.edu>
Content-Type: text/plain; format=flowed
Jack ,
There really isnt an equivalent 'In' operator for the macro language.
Toby Dunn
When everything is coming at you all at once, your in the wrong lane.
A truly happy person is someone who can smile and enjoy the scenery on a
detour.
From: Jack Clark <JClark@CHPDM.UMBC.EDU>
Reply-To: Jack Clark <JClark@CHPDM.UMBC.EDU>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Using the IN operator in %IF statement
Date: Fri, 1 Sep 2006 10:03:56 -0400
Good morning everyone.
I am creating a new macro variable called NEEDC. If the last word in the
formatted value of another macro variable (&WHCL) is 'City', 'State' or
'County', I want the value of NEEDC to be blank. Otherwise I want the value
of NEEDC to be the word County;
I have successfully tested and run the code below, simply checking for the
word 'City' as the last word in the formatted &WHCL:
%if %qscan( %bquote(%sysfunc(putc(&whcl,$cnty.))),-1,%str( ) ) = City %then
%do;
%let needc =;
%end;
%else %do;
%let needc = County;
%end;
When I tried to use the IN operator to check for 'City', 'State' or
'County', I am getting an error message in the log that says "Required
operator not found in expression". I have tried it with and without quotes
around the City, State and County :
%if %qscan( %bquote(%sysfunc(putc(&whcl,$cnty.))) ,-1,%str( ) ) in
(City,State,County) %then %do;
%let needc =;
%end;
%else %do;
%let needc = County;
%end;
I am not sure if this is related to the use of the IN operator in macro
code, or if there is a macro quoting problem with the three terms in the
parentheses. Can someone please give me some direction on this? I am
interested in a solution to make the code work, as well as an explanation as
to why my existing code is not valid.
Thank you.
Jack Clark
Research Analyst
Center for Health Program Development and Management
University of Maryland, Baltimore County