Dear Tom, Thank you very much. Your code does create different output sets on each DO LOOP iteration but the problem is that does not update the list of variables from iteration to iteration. It should be for i=1 table sex for i=2 table sex age etc. but it iterates only for the first value of i="sex" Any help? Thanking you in advance. please see attached the log 1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 61 62 data test; 63 input ID $ 1-4 Sex $ 6 Age 8-9 Height 11-12 Weight 14-16 64 Pulse 18-20 FastGluc 22-24 PostGluc 26-28; 65 datalines; NOTE: The data set WORK.TEST has 20 observations and 8 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.01 seconds 86 ; 87 run; 88 89 data _null_; 90 do vars="sex","sex age"; 91 i+1; 92 call execute(catx(' ' 93 ,'proc sort data=test; by',vars,'; run;' 94 )); 95 call execute(catx(' ' 96 ,'proc tabulate data=test out=',cats('pret',i),';' 97 ,'class',vars,';' 98 ,'var pulse;' 99 ,'table',vars,'ALL="Grand Total"' 100 ,', pulse="Group',i,'" * (N="Count" COLPCTN="%");' 101 ,'run;' 102 )); 103 end; 104 run; NOTE: DATA statement used (Total process time): real time 0.06 seconds cpu time 0.00 seconds NOTE: CALL EXECUTE generated line. 1 + proc sort data=test; by sex ; run; NOTE: There were 20 observations read from the data set WORK.TEST. NOTE: The data set WORK.TEST has 20 observations and 8 variables. NOTE: PROCEDURE SORT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 2 + proc tabulate data=test out= pret1 ; class sex ; var pulse; table sex ALL="Grand Total" , pulse="Group 1 " * (N="Count" COLPCTN="%"); run; NOTE: There were 20 observations read from the data set WORK.TEST. NOTE: The data set WORK.PRET1 has 3 observations and 6 variables. NOTE: PROCEDURE TABULATE used (Total process time): real time 0.09 seconds cpu time 0.09 seconds 3 + proc sort data=test; by sex ; run; NOTE: Input data set is already sorted, no sorting done. NOTE: PROCEDURE SORT used (Total process time): real time 0.00 seconds cpu time 0.01 seconds 4 + proc tabulate data=test out= pret2 ; class sex ; var pulse; table sex ALL="Grand Total" , pulse="Group 2 " * (N="Count" COLPCTN="%"); run; NOTE: There were 20 observations read from the data set WORK.TEST. NOTE: The data set WORK.PRET2 has 3 observations and 6 variables. NOTE: PROCEDURE TABULATE used (Total process time): real time 0.04 seconds cpu time 0.05 seconds 105 106 107 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 120
... View more