Hi, I have a dataset as below: Sample: For 3 Academic years, across 3 campuses I have Students which can fall into 4 different Status. I need to print a report.
Currently I export the data in Excel and then create a pivot on the data where I have Rows as AY Year and Campus and Column as Retain Status and Values as Count of (term1_student). I know in SAS also we can create pivots and tables but I am not able to create the table. I am relatively new to SAS and have tried Proc Freq, Proc tabulate, proc report, tableeditor files but I keep on getting into some or other errors. Your help is greatly appreciated.
AY Year Campus Retain_Status Term1_Student
2015-2016 Campus1 Retained uid1
2015-2016 Campus2 Retained uid2
2015-2016 Campus3 Retained uid3
2015-2016 Campus1 Withdrawn uid4
2015-2016 Campus1 Graduated uid5
2015-2016 Campus1 NOT Retained uid6
2015-2016 Campus2 Retained uid7
2015-2016 Campus3 Retained uid8
2015-2016 Campus2 Withdrawn uid9
2015-2016 Campus1 Graduated uid10
2016-2017 Campus1 Retained uid11
2016-2017 Campus2 Retained uid12
2016-2017 Campus3 Retained uid13
2016-2017 Campus1 Withdrawn uid14
2016-2017 Campus1 Graduated uid15
2016-2017 Campus1 NOT Retained uid16
2016-2017 Campus2 Retained uid17
2016-2017 Campus3 Retained uid18
2016-2017 Campus2 Withdrawn uid19
2016-2017 Campus1 Graduated uid20
2015-2016 Campus1 Retained uid21
2017-2018 Campus2 Retained uid22
2017-2018 Campus3 Retained uid23
2017-2018 Campus1 Withdrawn uid24
2017-2018 Campus1 Graduated uid25
2017-2018 Campus1 NOT Retained uid26
2017-2018 Campus2 Retained uid27
2017-2018 Campus3 Retained uid28
2017-2018 Campus2 Withdrawn uid29
2017-2018 Campus1 Graduated uid30
I want the report to look like below (The data values below are just made up in the below example but they are the number of students that fall into that status for the campus within Academic Year):
Graduated Retained Withdrawn Not Retained
2015-2016 Campus1 2 1 3 2
Campus2 1 4 1
Campus3 2 1 1
2016-2017 Campus1 2 1 3 2
Campus2 1 4 1
Campus3 2 1 1
2017-2018 Campus1 2 1 3 2
Campus2 1 4 1
Campus3 2 1 1
Thank you.
Hi:
With some fake data for a few years, and with grand totals, it looks like this with PROC TABULATE:
and like THIS with PROC REPORT
Cynthia
I can't run the code since you don;t provide the data in a usable format, but something like this should work:
proc tabulate;
table YEAR=' ' * CAMPUS=' ',STATUS=' ' * n=' ';
@ChrisNZ wrote:
I can't run the code since you don;t provide the data in a usable format, but something like this should work:
proc tabulate;
table YEAR=' ' * CAMPUS=' ',STATUS=' ' * n=' ';
Don't forget a CLASS statement to let the procedure know that Year, Campus and Status will be used as categorical variables. Tabulate is picky that way.
Hi:
With some fake data for a few years, and with grand totals, it looks like this with PROC TABULATE:
and like THIS with PROC REPORT
Cynthia
Hi Cynthia_sas,
Proc tabulate did the magic and I was able to move forward. For some reason, Proc Report kept on erroring and I was not able to get that to work. I think Proc report gives more control for subtotals etc. which Proc Tabulate might not do. But for now, I can move forward. I really appreciate your help. Learning slowly as I go. Thank you.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.