The SAS Output Delivery System and reporting techniques

stacking variables in proc report

New Contributor
Posts: 2

stacking variables in proc report

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;


define total/analysis;


final output

Demographics   Count percentage

M                       2     

F                       2

50-57                 1      

10-17                  1

19-29                  1          

Posts: 9,371

Re: stacking variables in proc report


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. (

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.


New Contributor
Posts: 2

Re: stacking variables in proc report

Posted in reply to Cynthia_sas

Thanks for the info Cynthia!

Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation