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

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.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  With some fake data for a few years, and with grand totals, it looks like this with PROC TABULATE:

Cynthia_sas_0-1604361022692.png

 

and like THIS with PROC REPORT

Cynthia_sas_1-1604364696675.png

 

Cynthia

View solution in original post

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

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=' ';

ballardw
Super User

@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.

Cynthia_sas
SAS Super FREQ

Hi:

  With some fake data for a few years, and with grand totals, it looks like this with PROC TABULATE:

Cynthia_sas_0-1604361022692.png

 

and like THIS with PROC REPORT

Cynthia_sas_1-1604364696675.png

 

Cynthia

Sangita1
Obsidian | Level 7

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 734 views
  • 0 likes
  • 4 in conversation