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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.