Date: Wed, 4 Mar 2009 14:10:10 +0000
Reply-To: karma <dorjetarap@GOOGLEMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: karma <dorjetarap@GOOGLEMAIL.COM>
Subject: Re: urgent
In-Reply-To: <200903041350.n24BkrR5030553@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1
Very nice Gerhard, and as macro variables are essentially text, this
works about as well as I would expect %in to work if it existed.
Thanks
2009/3/4 Gerhard Hellriegel <gerhard.hellriegel@t-online.de>:
> I sometimes also saw the %index function to do something like the IN
> operator:
>
> %macro test;
> %do i=1 %to 5;
> %if %index(*1*2*3*,&i) %then %do;
> %put ok for I=&i;
> %end;
> %else %do;
> %put &i is not in 1 2 3;
> %end;
> %end;
> %mend;
> %test;
>
> Gerhard
>
>
>
>
> On Wed, 4 Mar 2009 10:51:53 +0000, karma <dorjetarap@GOOGLEMAIL.COM> wrote:
>
>>You have a bit of a mixture of data step code and macro code here. The
>>macro language doesn't support the in function as of yet, so you can
>>either code the options explicitly in the macro code, or bring it into
>>the datastep.
>>
>>%macro test ;
>> %let i=1 ;
>> %if &i eq 1 or &i eq 2 or &i eq 3 %then
>> %let inds=eff_auc ;
>> %else %if &i eq 3 or &i eq 4 or &i eq 5 %then
>> %let inds=pk ;
>> %put &inds ;
>>%mend;
>>%test ;
>>
>>%let i=4 ;
>>data _null_ ;
>> if &i in (1 2 3) then call symputx('inds','eff_auc') ;
>> else if &i in (3 4 5) then call symputx('inds','pk') ;
>> run ;
>>%put &inds ;
>>
>>2009/3/4 Shaik Hymad <hymadsk@gmail.com>:
>>> Please correct the below statement :
>>>
>>>
>>>
>>> if &i in (1 2 6) then %let inds=eff_auc;
>>> %else %if &i in (3 4 5) %then %let inds=pk;
>>>
>
|