Getting row frequencies with Proc Report

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

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';
    DEFINE FR1 / across 'Score for Free Response' ;
        title 'Free Response 1: Percentages by Score Level';
    RUN;

 So, with proc report I get the following output.

LevelNR0001020304050607080910Total
128.5%19.3%7.5%2.6%1.3%0.6%......1033
250.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:

LevelNR0001020304050607080910Total
112%68%13%4%2%1%.0%.0%.0%.0%.0%.0%1033
25%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: 9,682

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;

View solution in original post


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

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: 9,682

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.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 286 views
  • 0 likes
  • 2 in conversation