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;

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!

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.

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
  • 1 reply
  • 2458 views
  • 0 likes
  • 2 in conversation