Date: Tue, 21 Oct 2003 16:48:46 -0500
Reply-To: greg.woolridge@TAP.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Greg Woolridge <greg.woolridge@TAP.COM>
Subject: Re: Macro array question
Content-type: text/plain; charset=us-ascii
I think the problem lies with your %LET statement. %LET cannot be
conditionally excuted except as part of a macro statement such as %IF &A
= %THEN %LET B=MISSING;. Try using the data step SCAN function and writing
your loop something like this:
do i = 1 to &nvars;
variab{i} = scan("&vars",i,' ')
end;
Greg M. Woolridge
Manager, Study Programming
TAP Pharmaceutical Products Inc.
e-mail: greg.woolridge@tap.com
phone: 847-582-2332
fax: 847-582-2403
"DePuy, Venita"
<depuy001@DCRI.D To: SAS-L@LISTSERV.UGA.EDU
UKE.EDU> cc:
Sent by: "SAS(r) Subject: Macro array question
Discussion"
<SAS-L@LISTSERV.
UGA.EDU>
10/21/2003 04:28
PM
Please respond
to "DePuy,
Venita"
Hi all -
yet another question regarding macros - but I think I'm at least making
progress!
In the following code, the 2 explanatory variables are S and Trt2.
Ideally I could have users enter the (appropriate) variables in the string,
separated by a space, and the number of variables in nvar.
I'm trying to do this with just 2 variables for starters.
I'm getting an error in the scan part; I've tried using i, {i}, . . . I
guess the main problem is how to use a variable for the position?
The point of the code - to separate out the string in &vars into var1, var2
. . .
Thanks for help, yet again!
-Venita
%let file=lognorm_2trts;
%let response = y;
%let nvars = 2;
%let vars = %str (s trt2);
> data &file.2;
>
> set &file;
> log_response = log(y+1);
> array variab{2} variab1 - variab2;
> do i = 1 to &nvars;
> %let v = %scan(&vars ,i,' ');
> variab{i} = symget('v');
> end;
> run;