Date: Wed, 2 May 2001 14:00:33 -0400
Reply-To: Myra Oltsik <moltsik@RESPONSE.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Myra Oltsik <moltsik@RESPONSE.COM>
Subject: Re: simple macro question - %let
Content-Type: text/plain; charset=ISO-8859-1
On Wed, 2 May 2001 10:22:31 -0400, Dan Fiscus <fiscus@AL.UMCES.EDU> wrote:
>This must be an easy one, but as fairly early on in getting the
>macro language, I am stumped...
>I want to store a dataset variable value into a macro variable.
>I have a dataset variable called x and want to store the current
>observation's value of x into the macro variable chosenx. But
>if I say (from inside a data step):
>%let chosenx = x ;
>the value of chosenx becomes the string 'x'.
>Thanks for any suggestions...
>Ecologist/Research Assistant email: firstname.lastname@example.org
>Appalachian Laboratory phone: 301-689-7121
>University of Maryland C.E.S. fax: 301-689-7200
>301 Braddock Road http://www.al.umces.edu
>Frostburg, MD 21532 USA
It's not exactly easy. Here's some code I use to do what I think you want
to do: [I have comments below.]
PROC SUMMARY DATA=NCLM.EARNPQ MISSING NWAY;
WHERE MASTERST NE 'NY';
FORMAT SEARNED DOLLAR20.2;
OUTPUT OUT=STATES(RENAME=(MASTERST=ST) DROP=_TYPE_ _FREQ_) SUM=;
SET STATES(KEEP=ST) NOBS=NO;
DO I = 1 TO &OBSV;
IF _N_ = I THEN DO;
%DO Z = 1 %TO &OBSV;
On it's first pass, &&STATE&Z resolves to &STATE1. On the next pass,
&STATE1 response to AZ (for Arizona). I learned this in Art Capenter's
Macro class about 1-½ years ago. I don't have the code memorized, but
always available when I need it.