If you want different stats for different fruits, then you might be better off runing proc means to generate all the stats for all the variables, CLASS-ified by fruit and vendor. Then you can select the combination of fruits, measures, and stats wanted. PROC TABULATE then simply become a display tool, since each cell comes from a single var in a single observations in the proc means output. That's why the example below can use the SUM= expression regardless of which stat is being reported. Below is a sample using sashelp.class (use sex for fruit, and agegroup for vendor). I also set it up so that you can get multiple measures and multiple stats for a single sex (fruit in the op example). Fill the macrovars in the order you want the columns filled. Of course, by the time you've run the PROC MEANS, there might be better ways to display results than proc tabulate, but since that's how we started ... Let's say you want, in this order, mean height for women, min weight for men, then max weight for men, by agegroup: %let sexlist= F M M; %let vars= height weight weight; %let stats = MEAN MIN MAX; data have; set sashelp.class; agegroup=1+(age>14); output; output; output; run; proc means data=have noprint nway &stats; class sex agegroup; var &vars; output out=need; run; data vtemp (KEEP=SEX AGEGROUP MEASURE DESCRIP W)/ view=vtemp; set need; array meas {*} &vars; do W=1 to dim(meas); sexvalue=scan("&sexlist",w); if sex=sexvalue then do; S= scan("&stats",W); if _stat_=S then do; measure=meas{W}; descrip=catx('-',scan("&vars",W),_stat_); output; end; end; end; run; proc sort data=vtemp out=temp; by w; run; proc tabulate data=temp noseps order=data ; class agegroup sex descrip; var measure; tables agegroup, sex * descrip=' ' * sum=' '*measure=' '; run;
... View more