LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2012, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 7 Mar 2012 14:37:35 -0600
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: Using IN operator in a macro XXXX
Comments: To: Dan Abner <dan.abner99@gmail.com>
In-Reply-To:  <CAPRGo-nugJqH6F8JLvi_i_DBi73M75nnQHx1rQxofiOfgT9uiw@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

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 >


Back to: Top of message | Previous page | Main SAS-L page