Dear Community,
I am having a strange issue with proc tabulate: using all keyword to display the totals is causing the class header to repeat. For example:
proc tabulate data=foo;
class var3 var4 var5;
var var1 var2;
table var4*var5, var3*var1*(sum pctsum<var2>);
quit;
only shows var4 and var5 names once, on the top of the table. On the other hand,
proc tabulate data=foo;
class var3 var4 var5;
var var1 var2;
table (var4 all)*(var5 all), var3*var1*(sum pctsum<var2>);
quit;
shows the var5 names on top of each var4 block. What is even stranger,
proc tabulate data=foo;
class var3 var4 var5;
var var1 var2;
table (var4 all)*(var5), var3*var1*(sum pctsum<var2>);
quit;
Has the var5 name repeated in the all block of var4 only. Has anyone experienced this and found a solution? Thank you for suggestions in advance.
Looks like the "issue" is even present in the documentation:
Division header is visible on top of Total region block.
Without the totals, division is only shown once on the top:
Not strange at all. It works as intended. You also missed some combinations of all in the row dimension.
BTW, you can have multiple tables statements in a single call to proc tabulate as long as you don't attempt to change the role of a variable or need different subsets of records used.
proc tabulate data=sashelp.class; class sex age; var height weight; table sex*age, height*sum; ; table (sex all)*age, height*mean ; table sex *(age all), height*mean ; table (sex all) *(age all), height*mean ; table all sex *(age all), height*mean ; run;
The second table includes a summary of All of the AGE groups, the third only has a summary within sex for all age groups, the fourth has the summary for all sexes with combined by age group and all age groups, the fifth has the summary of all records which is the same as the last row of the 4th table.
If you cross an All with any variable you will get combinations just as when you cross any other class variables. There is method to the madness and knowing which crosses you actually want are important.
This behaves similar to the Proc Freq tables statement when crossing variables and parentheses.
A request like : (sex all) *age is the same as: sex*age all*age.
proc tabulate data=sashelp.class; class sex age; var height weight; table sex*age all*age, height*mean ; table (sex all) *age, height*mean ; run;
extend that to a second and : (sex all) *(age all) becomes: sex*(age all) all*(age all)
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.