Solved
New Contributor
Posts: 2

# Getting row frequencies with Proc Report

I am trying to create a frequency table using proc report that will produce the frequency of responses to a free response question against the final score. I can do this with proc freq using the following code.

`````` proc freq data = e2 order = data;
tables FINAL * FR1/  nopercent nocol;
run;``````

But when I try this in proc report, I get the percentages in the cells at the column level rather than the row frequencies that I need. It must be the way I'm ordering the varaibles, but I think I have tried every configuration and I still cannot get this to work. Both FINAL and FR1 are character variables. The reason I need to use Proc report is that I also need to highlight values in the table. I can get the hightlighting to work but the output is not correct.

``````PROC REPORT DATA = E2 NOWD missing ;
COLUMNS FINAL FR1, pctn N ;
DEFINE FINAL / GROUP 'Level' ;
DEFINE PCTN / '' FORMAT=PERCENT7.1  ;
DEFINE N /  'Total';
title 'Free Response 1: Percentages by Score Level';
RUN;``````

So, with proc report I get the following output.

 Level NR 00 01 02 03 04 05 06 07 08 09 10 Total 1 28.5% 19.3% 7.5% 2.6% 1.3% 0.6% . . . . . . 1033 2 50.4% 56.1% 50.4% 46.8% 37.8% 20.7% 13.3% 7.0% 2.7% 1.5% 0.6% . 4924

But what I want is this, which was created with proc freq:

 Level NR 00 01 02 03 04 05 06 07 08 09 10 Total 1 12% 68% 13% 4% 2% 1% .0% .0% .0% .0% .0% .0% 1033 2 5% 41% 19% 15% 10% 5% 3% 1% 0% 0% 0% 0%. 4924

The basic question is, do I need to create a new computed varaible in order for SAS to create the row percentages that I want?  Or, am I missing something in my code to get the output that I need?

Accepted Solutions
Solution
‎05-10-2016 09:57 AM
Super User
Posts: 10,784

## Re: Getting row frequencies with Proc Report

For smmmary statistic , it is not good for proc report ,is good for proc tabulate .

``````proc tabulate data=sashelp.class ;
class sex age;
table sex=' ',age=' '*rowpctn=' ' n/ box='sex';
run;``````

All Replies
Solution
‎05-10-2016 09:57 AM
Super User
Posts: 10,784

## Re: Getting row frequencies with Proc Report

For smmmary statistic , it is not good for proc report ,is good for proc tabulate .

``````proc tabulate data=sashelp.class ;
class sex age;
table sex=' ',age=' '*rowpctn=' ' n/ box='sex';
run;``````
New Contributor
Posts: 2

## Re: Getting row frequencies with Proc Report

Thank you. I wondered if proc tabulate would be a better choice.

Super User
Posts: 10,784

## Re: Getting row frequencies with Proc Report

Yes. If there were only summary statistic like N , SUM , PCTN .... in your report ,  proc tabulate would be a better choice .

🔒 This topic is solved and locked.