Date: Mon, 28 Jun 2004 17:03:16 -0400
Reply-To: "Fehd, Ronald J. (PHPPO)" <RJF2@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Fehd, Ronald J. (PHPPO)" <RJF2@CDC.GOV>
Subject: Re: Dynamic Variable Problem, Help!!!
Content-Type: text/plain; charset="us-ascii"
> From: John J. Gilroy
> I am trying the following in an effort to create a dynamic
> variable name that is dependent on the difference, months
> (can change from observation to
> observation) between a date variable and the system date.
> Here is what I've tried, and now realize 2 reason it will not
> work (macro variables not resolved until datastep execution,
> and int function needs a number):
as always, the most important question is why?
do you want to do this?
and: How do you expect to use this
I-have-no-idea-what-the-var-name-is-now
variable in later data steps?
data structure is key to usage in an algorithm
but until you figure out what you're doing, later,
you'll need this:
DATA _Null_;
> Merge Dataset1 (In=A)
> Dataset2 (In=B);
> by custidno appseqno;
> If A and B then do;
> G2 = INTCK('MONTH',CONTDT,"&SYSDATE"D);
>****G1 = INPUT(G2,2.);
>*****LET GAP = %SYSFUNC(INT(G1));
call symput('Gap',compress(put(G2,32.)));
> Data Temp;
> or I would like to do:
** this is the data structure statement;
> Rename Balnet = Balnet⪆
> Merge Dataset1 (In=A)
> Dataset2 (In=B);
** rename probably ought to be in the data set options
for whichever data set has var Balnet:
Dataset? (In = Have?
rename = (Balnet = Balnet&Gap.)
)
> by custidno appseqno;
>
> If A and B then do;
>****Balnet&gap = Balnet;
** this is a copy statement in the algorithm.
>
> output;
> end;
> Run;
> How can I create these variable names on the fly???? Thanks, John
put the landing gear down first
Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov
Efficiency is intelligent laziness. -David Dunham