Date: Fri, 12 Jul 2002 09:52:29 -0400
Reply-To: Ed Heaton <EdHeaton@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ed Heaton <EdHeaton@WESTAT.COM>
Subject: Re: query: creating macro variables
Content-Type: text/plain
Don,
The following should do the trick. It creates a series of macro LET
statements and then uses those statements to assign your macro variables.
Data x ;
Input subject Y $ ;
Cards ;
1 A
2 AB
3 ABC
;
Proc sql /*noPrint*/ ;
Select
'%let subject' || /* Must use single-quotes here. */
trim( left( put(subject,5.) ) ) ||
"=" || trim(Y) || ";"
into :lets
from x
;
Quit ;
&lets
Ed
Edward Heaton, Senior Systems Analyst,
Westat (An Employee-Owned Research Corporation),
1550 Research Boulevard, Room 2018, Rockville, MD 20850-3195
Voice: (301) 610-4818 Fax: (301) 294-3992
mailto:EdwardHeaton@westat.com http://www.westat.com
-----Original Message-----
From: Don Aya [mailto:donsas99@HOTMAIL.COM]
Sent: Thursday, July 11, 2002 5:47 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: query: creating macro variables
Hello SAS-Lers;
I have a macro question which I hope you can help.
Suppose I have the following data set:
data x;
input subject Y $;
cards;
1 A
2 AB
3 ABC
;
run
I want to creat macro variables for each subject such that
&subject1 has 'A'
&subject2 has 'AB'
&subject3 has 'ABC'
I highly appreciate your help.
Thanks.
Don
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com