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.
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.