When I use proc tabulate it is not showing all of the categories under my variable. Here is my code:
proc tabulate data=combined ;
class obese;
var racenew;
table racenew,
obese='Obese'*(n=' '*f=comma12.0 pctsum=' '*f=pctfmt.) ;
format racenew racenew. obese obese. ;
run;
Here is a picture of what comes out:
3,168 | (7.94%) | 36,482 | (92.06%) |
I want it to show the categories of 'Race'. Ex: Race
Native American
Caucasian
African American
I just figured it out!
Here is my code:
proc tabulate data=combined ;
class obese racenew;
table racenew,
obese='Obese'*(n=' '*f=comma12.0 pctn=' '*f=pctfmt.) ;
format racenew racenew. obese obese. ;
run;
To get the report you have shown, RACENEW must be part of the CLASS statement, not part of the VAR statement.
What are you trying to sum here? Is there some other variable that you haven't mentioned? Or do you actually need PCTN instead of PCTSUM?
So basically, I am wanting the Race categories to show. I am not sure how to code that though. I want it to show both 'Obese' and 'Race' categories like the above picture.
I just figured it out!
Here is my code:
proc tabulate data=combined ;
class obese racenew;
table racenew,
obese='Obese'*(n=' '*f=comma12.0 pctn=' '*f=pctfmt.) ;
format racenew racenew. obese obese. ;
run;
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!
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.