Hi all,
I have a macro [ %reg] where I have an argument [varlist] which is a variable list. This will contain variable names, delimited by a blank or blanks, and the total number of variable names passed to varlist itself can vary.
A simple version of my code looks like this:
----------------------------------------------------------------------------
data a;
input y x1 x2 x3 x4_old x4_new;
datalines;
1 8 7 2 4 7
3 4 6 2 7 2
9 0 2 1 7 -9
9 5 3 8 7 0
0 9 8 3 5 -7
;
run;
options symbolgen;
%macro lin(method,varlist);
proc reg data =a;
model y = &varlist/&method;
run;
%let varcnt=%sysfunc(countw(&varlist));
%put There are &varcnt variables in the model;
data _null_;
set a;
%do i=1 %to &varcnt;
%let var&i =%qscan(&varlist,&i);
%put var&i = &&var&i;
%end;
run;
%mend lin;
--------------------------------------------------------------------------
%lin(all, x1 x2 x4_old); > invoking the macro in this way gives desired results.
Now, I want to put in a sum statement like the following :
z=sum( all the variables that are in varlist).
eg z = sum(x1,x2,x4_old) ;
Obviously, I need a comma seperated variable list. Can any one please show me the quickest way to do this? Thanks a lot for your help!!
Best, wbguy