Date: Tue, 9 Feb 2010 01:44:39 -0800
Reply-To: Amar Mundankar <amarmundankar@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Amar Mundankar <amarmundankar@GMAIL.COM>
Organization: http://groups.google.com
Subject: Re: How to use IN operator in %if condition (i.e. inside Macro)
in SAS 9.1.3
Content-Type: text/plain; charset=ISO-8859-1
On Feb 9, 1:20 pm, Amar Mundankar <amarmundan...@gmail.com> wrote:
> Hi all,
> How can we use the IN operator for %if condition inside a macro ??
> I am using SAS 9.1.3.
> I tried to use # , but it didnt work. what can be the problem ??
> It is throwing an error as :
>
> 67 data temp;
> 68 do i = 1 to 2;
> 69 %mymac(one=on);
> MLOGIC(MYMAC): Beginning execution.
> MLOGIC(MYMAC): Parameter ONE has value on
> SYMBOLGEN: Macro variable ONE resolves to on
> SYMBOLGEN: Macro variable GRP resolves to ('on', 'off')
> ERROR: Required operator not found in expression: &one # &grp
> ERROR: The macro MYMAC will stop executing.
> MLOGIC(MYMAC): Ending execution.
> 70 end;
> 71 run;
>
> Please help.
>
> Code:
>
> %macro mymac(one=on);
> %if &one # &grp %then %do ;
> %put condition true;
> %end;
> %else %do;
> %put condition false;
> %end;
> %mend;
>
> data temp;
> do i = 1 to 2;
> %mymac(one=on);
> end;
> run;
>
> Regards,
> Amar Mundankar.
i forgot to paste %let statement.
Updated code :
%let grp = ('on', 'off');
%macro mymac(one=on);
%if &one # &grp %then %do ;
%put condition true;
%end;
%else %do;
%put condition false;
%end;
%mend;
data temp;
do i = 1 to 2;
%mymac(one=on);
end;
run;
Regards,
Amar Mundankar.
|