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:
| Week | Accept | Reject |
| 1 | 2 | 1 |
| 2 | 2 | 1 |
| 3 | 3 | 0 |
| 4 | 3 | 0 |
Any help would be greatly appreciated!
Thank you!
@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.
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 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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.