I tried this for different questions and my code looks likethis: %macro stuff(); %let varlist = Q4 Q6 Q7 Q10 Q13; %do i=4 %to %sysfunc(countw(&varlist.)); %let var=%scan(&varlist.,&i.); proc sql noprint; create table test&i. as select role, cats(count(Q&i.),'(',put(count(Q&i.)/count(*),percent8.),')') as C&i. from data group by role; quit; %end; %mend stuff; %stuff; Its giving me only 4 test data, test 4 test 5 test 6 and test 7. Also, I want my test data to br named as my selected questions. for eg: with above example the test data should be test 4, test 6, test 7, test 10 and test 13.
... View more