Date: Mon, 21 May 2007 10:56:27 -0400
Reply-To: "data _null_;" <datanull@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "data _null_;" <datanull@GMAIL.COM>
Subject: Re: 'IN' Statment in Macro
In-Reply-To: <BAY123-F302530CA5A6C924A5714BDDE370@phx.gbl>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
The IN "operator".
= EQ equal to a=3
^= NE not equal to (table note 1) a ne 3
¬= NE not equal to
~= NE not equal to
> GT greater than num>5
< LT less than num<8
>= GE greater than or equal to (table note 2) sales>=300
<= LE less than or equal to (table note 3)
sales<=100
IN equal to one of a list num in (3, 4, 5)
It is documented as an operator and it works in IFN IFC, so why not
when IFN, IFC is called in SYSFUNC. Maybe I just don't have the
syntax correct.
On 5/21/07, toby dunn <tobydunn@hotmail.com> wrote:
> Data _Null_ ,
>
> The In operator is a construct of the Data Step, while Sysfunc allows one to
> use a data step function out of its normal context you have proven that it
> does not extend betond that scope. The In operator is not a function nor is
> it something unique to any function.
>
>
>
> Toby Dunn
>
> On the other hand, you have different fingers. ~ LCG
>
> The early bird may get the worm, but the second mouse gets the cheese in the
> trap. ~ LCG
>
> What happens if you get scared half to death, twice? ~ LCG
>
>
>
>
>
> From: "data _null_;" <datanull@GMAIL.COM>
> Reply-To: "data _null_;" <datanull@GMAIL.COM>
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: 'IN' Statment in Macro
> Date: Mon, 21 May 2007 09:57:30 -0400
>
> Seems like IFC or IFN with SYSFUNC might be helpful. But I could not
> get it to work as expected.
>
> 123 *if this works;
> 124 data _null_;
> 125 y = 1;
> 126 x = ifn(y in(1,3),20,30,.);
> 127 put _all_;
> 128 run;
>
> y=1 x=20 _ERROR_=0 _N_=1
> NOTE: DATA statement used (Total process time):
> real time 0.00 seconds
> cpu time 0.00 seconds
>
>
> 129
> 130
> 131 *why no this;
> 132 %let y = 1;
> 133 %let x = %sysfunc(ifn(&y in(2 3),10,20));
> ERROR: Required operator not found in expression: 1 in(2 3)
> ERROR: Argument 1 to function IFN referenced by the %SYSFUNC or
> %QSYSFUNC macro function is not a
> number.
> ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC
> argument list. Execution
> of %SYSCALL statement or %SYSFUNC or %QSYSFUNC function
> reference is terminated.
> 134 %put _user_;
> GLOBAL X .
> GLOBAL Y 1
>
>
> On 5/21/07, toby dunn <tobydunn@hotmail.com> wrote:
> >Rajat ,
> >
> >No you cant use the In operator like this in the Macro Facility. Switch to
> >something that like IndexC or IndexW.
> >
> >
> >%If %Sysfunc( IndexW( 1 2 3 , &Variable ) ) %Then <Do Something>
> >
> >
> >Toby Dunn
> >
> >On the other hand, you have different fingers. ~ LCG
> >
> >The early bird may get the worm, but the second mouse gets the cheese in
> >the
> >trap. ~ LCG
> >
> >What happens if you get scared half to death, twice? ~ LCG
> >
> >
> >
> >
> >
> >From: Rajat Mathur <rajat2000@GMAIL.COM>
> >Reply-To: Rajat Mathur <rajat2000@GMAIL.COM>
> >To: SAS-L@LISTSERV.UGA.EDU
> >Subject: 'IN' Statment in Macro
> >Date: Mon, 21 May 2007 09:12:08 -0400
> >
> >Hi,
> >
> >I am having trouble in using 'IN' statment in Macro.
> >
> >Without Macro 'IN' works fine:
> >if variable in (some values) then <do something>
> >
> >but in macro
> >
> >%if &variable in (1 2 3) %then <do something>
> >
> >the above text doesnt work.
> >
> >Please let know me as how can I use 'IN' for macro.
> >
> >Thanks
> >Rajat
> >
> >_________________________________________________________________
> >Make every IM count. Download Messenger and join the i'm Initiative now.
> >It's free. http://im.live.com/messenger/im/home/?source=TAGHM_MAY07
> >
>
> _________________________________________________________________
> Make every IM count. Download Messenger and join the i'm Initiative now.
> It's free. http://im.live.com/messenger/im/home/?source=TAGHM_MAY07
>
|