BookmarkSubscribeRSS Feed
js5
Pyrite | Level 9 js5
Pyrite | Level 9

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.

2 REPLIES 2
js5
Pyrite | Level 9 js5
Pyrite | Level 9

Looks like the "issue" is even present in the documentation:

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=proc&docsetTarget=n1ql5xn...

Division header is visible on top of Total region block.

Without the totals, division is only shown once on the top:

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=proc&docsetTarget=p13k5zc...

ballardw
Super User

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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 474 views
  • 0 likes
  • 2 in conversation