BookmarkSubscribeRSS Feed
dgrolling
Calcite | Level 5

In SAS 9.4, I have a proc tabulate data block that produces a table of row percentages. I need a new column at the end that displays the total count of the row in the table. I'm getting an error about mixed/multiple statistics:

 

"ERROR: There are multiple statistics associated with a single table cell in the following nesting: All * RowPctN * f * All * Sum."

 

PROC TABULATE DATA = CHSS2017_s1 f=10.2 S=[just=c cellwidth=75]; 

CLASS AGE SEX Q21;

CLASSLEV AGE      / style=[font_weight=medium];
CLASSLEV SEX      / style=[font_weight=medium];
CLASSLEV Q21;
*FREQ REGIONWT;

TABLE ALL  	  = 'Greater Cincinnati Residents' * (ROWPCTN='	'*f=PCTF.)
	  AGE 	  = 'Age'   		 * (ROWPCTN='	'*f=PCTF.)
      SEX     		    		 * (ROWPCTN='	'*f=PCTF.)
	  , Q21 all=' '*sum;

RUN;

How can I replicate the table shown in this ticket? All three variables (age, sex, and q21) are categorical variables; the values for age and sex by q21 should be row pct, but each group within age and sex should have its own row count at the end of the table.

 

Capture.PNG

1 REPLY 1
ballardw
Super User

To avoid crossing statistics place them all in one dimension such as

 

PROC TABULATE DATA = CHSS2017_s1 f=10.2 S=[just=c cellwidth=75]; 

CLASS AGE SEX Q21;

CLASSLEV AGE      / style=[font_weight=medium];
CLASSLEV SEX      / style=[font_weight=medium];
CLASSLEV Q21;
*FREQ REGIONWT;

TABLE ALL  	  = 'Greater Cincinnati Residents'
	   AGE 	  = 'Age'   		 
      SEX     		    		 
	  , Q21* (rowpctn=' '*f=Pctf. all=' '*n);

RUN;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 2945 views
  • 0 likes
  • 2 in conversation