Date: Wed, 7 Mar 2012 12:49:29 -0800
Reply-To: Mary Rosenbloom <mary.rosenbloom.sas@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mary Rosenbloom <mary.rosenbloom.sas@GMAIL.COM>
Subject: Re: Using IN operator in a macro XXXX
In-Reply-To: <CAPRGo-ka-FiJ=_4wZ0m05Svy=Vm9UY+7mCJXy3mC0vppcCNx9g@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
When I looked at this code, the first thing that jumped out at me is that I
usually use parenthesis with IN, and surround the arguments with quotes
(unless they are numeric). How is it that you are getting away with not
using them:
%IF %SUBSTR(&VAR1,1,2) IN R_,Q_,O_,N_ %THEN %LET YES = 1;
vs
%IF %SUBSTR(&VAR1,1,2) IN ("R_","Q_","O_","N_") %THEN %LET YES = 1;
Thanks for your comments! I know I'm missing the boat on this, but can't
figure out why.
Cheers,
Mary R.
On Wed, Mar 7, 2012 at 12:40 PM, Dan Abner <dan.abner99@gmail.com> wrote:
> That did it! Thanks Joe!
>
>
>
>
> On Wed, Mar 7, 2012 at 3:37 PM, Joe Matise <snoopy369@gmail.com> wrote:
> > I think the MINDELIMITER defaults to %STR( ) [ie, space]. You need to
> use
> > spaces or change MINDELIMITER to , I believe.
> >
> > -Joe
> >
> >
> > On Wed, Mar 7, 2012 at 2:34 PM, Dan Abner <dan.abner99@gmail.com> wrote:
> >>
> >> Hi everyone,
> >>
> >> I am attempting to use the IN operator at the macro level, however,
> >> it is not producing the desired/expected results. I was expecting the
> >> macro variable YES's value to be changed from 0 to 1. I have the
> >> following code:
> >>
> >> ===
> >>
> >>
> >> %LET VAR1 = Q_VARIABLE;
> >>
> >>
> >> %MACRO TEST();
> >> OPTIONS MINOPERATOR;
> >>
> >> %LET YES = 0;
> >>
> >> %IF %SUBSTR(&VAR1,1,2) IN R_,Q_,O_,N_ %THEN %LET YES = 1;
> >>
> >> %PUT SUBSTR = %SUBSTR(&VAR1,1,2);
> >> %PUT YES = &YES;
> >>
> >> %MEND;
> >>
> >> %TEST()
> >>
> >>
> >> * =============================================================;
> >>
> >> I am getting in the log:
> >>
> >> ====
> >>
> >> 85
> >> 86 %LET VAR1 = Q_VARIABLE;
> >> 87
> >> 88
> >> 89 %MACRO TEST();
> >> 90 OPTIONS MINOPERATOR;
> >> 91
> >> 92 %LET YES = 0;
> >> 93
> >> 94 %IF %SUBSTR(&VAR1,1,2) IN R_,Q_,O_,N_ %THEN %LET YES = 1;
> >> 95
> >> 96 %PUT SUBSTR = %SUBSTR(&VAR1,1,2);
> >> 97 %PUT YES = &YES;
> >> 98
> >> 99 %MEND;
> >> 100
> >> 101 %TEST()
> >> MLOGIC(TEST): Beginning execution.
> >> MLOGIC(TEST): %LET (variable name is YES)
> >> MLOGIC(TEST): %IF condition %SUBSTR(&VAR1,1,2) IN R_,Q_,O_,N_ is FALSE
> >> MLOGIC(TEST): %PUT SUBSTR = %SUBSTR(&VAR1,1,2)
> >> SUBSTR = Q_
> >> MLOGIC(TEST): %PUT YES = &YES
> >> YES = 0
> >> MLOGIC(TEST): Ending execution.
> >>
> >> ===
> >>
> >> Any ideas why this is not working?
> >>
> >> Thanks!
> >>
> >> Dan
> >
> >
>
--
Cheers,
Mary F. O. Rosenbloom
http://www.sascommunity.org/wiki/User:Otterm1
|