BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Davanden
Obsidian | Level 7

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?

 

 

.  table shell.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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.

View solution in original post

5 REPLIES 5
Astounding
PROC Star

PROC TABULATE does that easily enough.

 

 

What are the variable names?

Davanden
Obsidian | Level 7

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.

ballardw
Super User

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 

;

Astounding
PROC Star

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.

Davanden
Obsidian | Level 7

Thanks to everyone who replied.  I'm glad the answer was so simple.

 

--Dav

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1632 views
  • 0 likes
  • 3 in conversation