BookmarkSubscribeRSS Feed
Simmi
Calcite | Level 5


Hi All,

I'm creating a table using proc report and would appreciate some insight on stacking multiple variables into a single column in a table in proc report. I have done this using proc tabulate but struggling to produce the same report using proc Report.

My question would be how would I stack multiple column variables in a single column in table so that it becomes easy for me to compute count and percentage on the data across.

my column variables are

   sex    Age   County  total

   M      57     Travis  120

  F       13    William  100

  M      21    Bexar  123

  F      19      william 145

proc report data=test2;

column SEX AGE COUNTY total, (n  pctn);

define sex/group;

define age/ group;

defineCounty/across;

define total/analysis;

run;

final output

Demographics   Count percentage

M                       2     

F                       2

50-57                 1      

10-17                  1

19-29                  1          

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

Hi,

What you want to do is not an "out of the box" type of report that PROC REPORT will create. First, you have to presummarize the data. Then generally with reports like this you will need to massage the data a bit in order to make variables in the order that you want. In my paper, called "Creating Complex Reports", I show 3 different examples of somewhat similar demographic reports. (http://www2.sas.com/proceedings/forum2008/173-2008.pdf)

The code is too lengthy to post here, but the general outline of the code process is in the paper. The zip file of program examples, can be found at  Technical Papers and Presentations made by SAS staff  you will need to scroll down to 2008 to find the paper by title.

cynthia

Simmi
Calcite | Level 5

Thanks for the info Cynthia!

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
  • 2 replies
  • 2361 views
  • 0 likes
  • 2 in conversation