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 (January 2007, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 29 Jan 2007 15:30:46 -0500
Reply-To:     Ed Heaton <EdHeaton@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ed Heaton <EdHeaton@WESTAT.COM>
Subject:      Re: Set problem
Comments: To: "Ross, Michael D" <michael.ross@astrazeneca.com>
In-Reply-To:  <5CA9E4A75962F64CA658FD81C05D6A01161B05@usuwamembx05.americas.astrazeneca.net>
Content-Type: text/plain; charset="us-ascii"

Michael;

The in operator doesn't work that way. It compares a variable with a list of values. You're trying to compare a value with a list of values. Are you willing to make the list of values in &testds a space delimited list?

%let mem = 'XXXXXXXX' ; %let testds = 'XXXXXXXX' 'YYYYYYYY' 'ZZZZZZZZ' ;

Data a ; x = 'First Condition True ' ; y = '1' ; Run ; Data b ; x = 'Second Condition True' ; y = '1' ; Run ;

%macro vIn( value , values ) ; %local tests ; %let tests = %sysFunc( tranWrd( &values , %str( ) , %str( %) or %( &value eq ) ) ) ; ( ( &value eq &tests ) ) %mEnd vIn ;

%macro testIt( mem , testDs ) ; Data test ; If %vIn( &mem , &testDs ) then set a (drop=y) ; Else set b ; Run ; %mEnd testIt ; %testIt( &mem , &testDs )

Now, the problem remains that you still have a Y column in TEST. That's because it allocated it at compile time from table B. Of course, it has no value because it did not pick one up from A.

Ed

Ed Heaton RW-4541 #4818

-----Original Message----- From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of Ross, Michael D Sent: Monday, January 29, 2007 2:49 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Set problem

This code doesn't drop the y variable, when first conditon is true. Any suggestions?

%let mem = 'XXXXXXXX'; %let testds = 'XXXXXXXX', 'YYYYYYYY', 'ZZZZZZZZ';

data a; x='First Condition True ' ;y='1'; run; data b; x='Second Condition True' ;y='1'; run;

%macro testit; data test; if &mem in (&testds) then do; set a (drop=y); end; else do; set b; end; run; %mend testit; %testit;


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