loops - looping over character values in SAS -
in stata can loop on list of character values foreach command. i've been trying same in sas no avail far. i'm trying run series of data , proc statements on values of character column. tried following:
%let mylist = b c; * these values of column called "code"; data mydata_@mylist; * each element creates new table; set mydata; code=&mylist; run;
what doing wrong or missing?
thanks in advance,
matÃas
try this:
%macro loopit(mylist); %let n = %sysfunc(countw(&mylist)); %do i=1 %to &n; %let val = %scan(&mylist,&i); data mydata_&val; set mydata; code = "&val"; run; %end; %mend; %let list=a b c; %loopit(&list);
Comments
Post a Comment