01-11-2018 10:25 PM - edited 01-11-2018 11:27 PM
Hi! Suppose I have dataset as followings
ID SEX RACE AGE
1 F Non-hispanic White 5-15
2 M Asian/Other 5-15
3 M Asian/Other 15-20
4 F Hispanic 15-20
5 M Hispanic 15-30
6 M Non-hispanic Black 25-30
I want to create a table as following
I know how to use proc sql without sub-section age group but is there a way to aggregate all age sections in one step? Thanks!
01-11-2018 10:53 PM - edited 01-11-2018 11:00 PM
Please try this.
proc freq data=have order=data;
table sex*age/norow nocum nofreq nopercent ;
01-11-2018 11:29 PM
Thank you! I just updated my question. This problem is after running your code there is still a "total N" column and row. I need to generate all percentage tables using all variables with age, so my output need to be a dataset or table for future modification.
01-12-2018 12:14 PM
A report table could look something like:
proc tabulate data=have; class age sex race ; table sex race , age=''*colpctn='' /misstext='0' ; run;
add other categorical variables to the class and table.
Note that this will only work if all records have values for all of the variables as tabulate by default excludes records with any missing values for the variables on a class statement OR add /missing to the Class statement to get missing treated as a category.
01-12-2018 11:04 AM