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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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