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