The SAS Output Delivery System and reporting techniques

Need help with Proc report

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Need help with Proc report

Hi SAS experts,

Although I am using SAS for a while now, I am a newbie to PROC REPORT. I am trying to create a simple report using following data

GroupVALUEstateFrequencyColPercent
AYes1150
BYes1675
CYes1654.54545455
DYes11052.63157895
EYes11161.11111111
ANo1150
BNo1225
CNo1545.45454545
DNo1947.36842105
ENo1738.88888889
AYes0150
BYes0337.5
CYes0654.54545455
DYes0421.05263158
EYes0844.44444444
ANo0150
BNo0562.5
CNo0545.45454545
DNo01578.94736842
ENo01055.55555556

I wrote following code :

proc report data=book1   ;

column group state  value, (Frequency ColPercent) ;

define group / "Group" left order;

define state / "State" center ;

define value/ "Response" center across;

define Frequency / "Counts" center format=3.;

define ColPercent / "Percent" center format=5.1;

title;

run;

Procedure is producing following table

Response
NoYes
GroupStateCountsPercentCountsPercent
A1..150
1150..
0..150
0150..
B1..675
1225..
0..337.5
0562.5..
C1..654.5
1545.5..
0..654.5
0545.5..
D1..1052.6
1947.4..
0..421.1
01578.9..
E1..1161.1
1738.9..
0..844.4
01055.6..

However, I want table in following format:

Response
NoYes
GroupStateCountsPercentCountsPercent
A1150150
0150150
B1225675
0562.5337.5
C1545.5654.5
0545.5654.5
D1947.41052.6
01578.9421.1
E1738.91161.1
01055.6844.4

So I want value of response (count and percent) for each state in a single line. For some reason PROC report is using two lines for same group. I tried using dummy variable bu it did not work out.

I would appreciate your help.

Thanks


Accepted Solutions
Solution
‎01-11-2013 09:21 AM
SAS Super FREQ
Posts: 8,717

Re: Need help with Proc report

Hi:

  To collapse rows (summarize your groups), which is what you want, change your usage of ORDER to GROUP in the DEFINE statements for GROUP and STATE -- otherwise, you are getting the default of DISPLAY for STATE and that is preventing anything from being summarized (or collapsed down to 1 row).

  Again, there is a really, really good documentation topic called "How PROC REPORT Builds a Report" that describes the "side effect" of DISPLAY (the default for character), ORDER and GROUP usages.

cynthia

View solution in original post


All Replies
Solution
‎01-11-2013 09:21 AM
SAS Super FREQ
Posts: 8,717

Re: Need help with Proc report

Hi:

  To collapse rows (summarize your groups), which is what you want, change your usage of ORDER to GROUP in the DEFINE statements for GROUP and STATE -- otherwise, you are getting the default of DISPLAY for STATE and that is preventing anything from being summarized (or collapsed down to 1 row).

  Again, there is a really, really good documentation topic called "How PROC REPORT Builds a Report" that describes the "side effect" of DISPLAY (the default for character), ORDER and GROUP usages.

cynthia

New Contributor
Posts: 2

Re: Need help with Proc report

Thanks for your help. I will read the documentation you suggested.

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 181 views
  • 0 likes
  • 2 in conversation