BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hwangnyc
Quartz | Level 8

Hi everyone,

 

I'm trying to create a report using PROC Report:

 

Here is the data and code:

data dataexercise;
input Week @@ Status $;
datalines;
1 Accept
2 Accept
3 Accept
4 Accept
1 Reject
2 Reject
3 Accept
4 Accept
1 Accept
2 Accept
3 Accept
4 Accept
;
run;


proc tabulate data=dataexercise;
class week Status ;
table
week*Status;
run;

 

 

Instead of the weeks going horizontally. This is what I would like:

 

WeekAcceptReject
121
221
330
430

 

Any help would be greatly appreciated!

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@hwangnyc wrote:
Hi Ballardw,

THANK YOU! This is perfect. Can you tell me how I can sum across the rows?
proc tabulate data=dataexercise;
   class week Status ;
   table
       week=' ',
      Status=' ' All='Row total'
      /box=week;
run;

will do a row count total for all records in the week

proc tabulate data=dataexercise;
   class week Status ;
   table
       week=' ' all='Column Total',
      Status=' '
      /box=week;
run;

Will do the total across the weeks and;

 

proc tabulate data=dataexercise;
   class week Status ;
   table
       week=' ' all='Column Total',
      Status=' ' all='Row Total'
      /box=week;
run;

Will provide a total of both row and column.

 

All can be used in parentheses to  work with different groups of values.

 

Be aware that Proc Tabulate by default will only include records that have values for all of the Class variables by default.

View solution in original post

3 REPLIES 3
ballardw
Super User
proc tabulate data=dataexercise;
   class week Status ;
   table
       week=' ',
      Status=' '
      /box=week;
run;

The comma is used in tabulate to separate the role from page, row or column. With only two dimensions the first is row, and second is column. The =' ' suppresses the variable label and the /box= option places the label of the variable Week inside the upper left corner of the table.

hwangnyc
Quartz | Level 8
Hi Ballardw,

THANK YOU! This is perfect. Can you tell me how I can sum across the rows?
ballardw
Super User

@hwangnyc wrote:
Hi Ballardw,

THANK YOU! This is perfect. Can you tell me how I can sum across the rows?
proc tabulate data=dataexercise;
   class week Status ;
   table
       week=' ',
      Status=' ' All='Row total'
      /box=week;
run;

will do a row count total for all records in the week

proc tabulate data=dataexercise;
   class week Status ;
   table
       week=' ' all='Column Total',
      Status=' '
      /box=week;
run;

Will do the total across the weeks and;

 

proc tabulate data=dataexercise;
   class week Status ;
   table
       week=' ' all='Column Total',
      Status=' ' all='Row Total'
      /box=week;
run;

Will provide a total of both row and column.

 

All can be used in parentheses to  work with different groups of values.

 

Be aware that Proc Tabulate by default will only include records that have values for all of the Class variables by default.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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