- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
PROC TABULATE does that easily enough.
What are the variable names?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks to everyone who replied. I'm glad the answer was so simple.
--Dav