I have a dataset with characteristics of households. I want to produce a table similar to the one in the picture below. The relevant point is that the columns are a categorical variable, while the rows are summary statistics. It's easy to do the opposite in TABULATE or REPORT, putting the categories on the rows and the summary statistics in the columns. I could write the output to a dataset, transpose it, and then print it. I could compute the statistics with PROC SUMMARY and then do something similar. I'm hoping to find a less complicated solution.
Is there some way to produce what I want in one step?
.
Just for discussion purposes, then, how about:
proc tabulate data=have;
class household_type;
var ichil numpeople mild moderate severe;
tables (numpeople ichil) * (sum mean) (severe moderate mild) * sum='Households',
all household_type;
run;
This is just to get the structure right. We can always worry about the labeling later.
I can't test the code right now, so you may need to debug it a little.
PROC TABULATE does that easily enough.
What are the variable names?
Number of persons in household is NUMPEOPLE
Number of children in household is ICHIL
The problem measures are flags. For discussion purposes, call them SEVERE, MODERATE, and NONE.
If you get what you want with tabulate but need to transpose the output then just change the order in the TABLE statement.
You likey currently have something like
Table Classvar1 Classvar2 Classvar3 ,
Var1*(n mean) Var2*(n mean)
;
just change the order to
Table Var1*(n mean) Var2*(n mean) ,
Classvar1 Classvar2 Classvar3
;
Just for discussion purposes, then, how about:
proc tabulate data=have;
class household_type;
var ichil numpeople mild moderate severe;
tables (numpeople ichil) * (sum mean) (severe moderate mild) * sum='Households',
all household_type;
run;
This is just to get the structure right. We can always worry about the labeling later.
I can't test the code right now, so you may need to debug it a little.
Thanks to everyone who replied. I'm glad the answer was so simple.
--Dav
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: