Date: Mon, 17 Jun 2002 22:22:38 -0400
Reply-To: "Schulingkamp, Michael E" <michael.e.schulingkamp@LMCO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Schulingkamp, Michael E" <michael.e.schulingkamp@LMCO.COM>
Subject: Building lists from macro vars
Content-type: text/plain
I'm having trouble dynamically creating variable lists inside a macro. I
have a program that creates a bunch of macro variables which hold the
variables to use in a proc summary step based on selections from a users
inputs. For example,
byvar1, byvar2, byvar3,...,byvar&i hold the variables for the BY line
and
var1, var2, var3,..., var&i hold the variables for the VAR line in the
proc.
I want to do something like:
%macro sum ;
%do i=1 to 50 ;
%if %mvarexists(&byvar&i) %then %let byvars = &byvars &byvar&i ;
/**** if this is even possible ****/
%if %mvarexists(&var&i) %then %let vars = &vars &var&i ;
%end;
proc summary;
by &byvars ;
var &vars ;
output out=sumout sum= ;
run;
%mend;
I've got the macro "mvarexists" written and working (thanks to the SAS-L
archives!).
Thanks,
Mike
|