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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -