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

Hello! 

Finding proc report syntax to be a bit tricky. I am attempting to count a variable (below - I am attempting to count the caseid variable so that I have the number of cases in each employee's queue) and add it to the summary line. I couldn't come up with a way to just display the count of the caseid variable in the summary line without also creating a column for it. The summary line also the includes the count of the days variable, which I do not need and would prefer to exclude. Is there a better way to be doing this? 

 

This is my current code: 

 

proc report nowd data=test;
column employee caseid n days ;
define employee/ group ;
define n / "count";
break after caseid / summarize Ol UL;
rbreak after /summarize;

run; 

 

This is the current output: 

Employee CaseIDCountDays
Michael Smith 1234-55 5
 1256-99 7
Michael Smith  212
Jane Doe  7890-10 1
 2233-55 2
 6789-12 4
Jane Doe  37

 

I was hoping more for this - days is not including in the summary line and ideally (though not as crucial) count of cases would be hidden as a column. 

Employee CaseIDDays
Michael Smith 1234-555
 1256-997
Michael Smith 2 
Jane Doe  7890-101
 2233-552
 6789-127
Jane Doe 3 
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26

Hi:

  What you describe is possible, but will take a COMPUTE block to accomplish. Since you did not supply any data, I used some fake data and I think the report you want is the #3 report shown below:

Cynthia_sas_0-1668723722807.png

 

  Some of your options (like OL and UL) did not make sense for ODS destinations because those are LISTING only options. Also, I put the text "Total Cases" on the last RBREAK row to make it clear what the number was under the CASEID cell. Most of the changes happen in the COMPUTE block for days.

Cynthia

View solution in original post

3 REPLIES 3
Cynthia_sas
Diamond | Level 26

Hi:

  What you describe is possible, but will take a COMPUTE block to accomplish. Since you did not supply any data, I used some fake data and I think the report you want is the #3 report shown below:

Cynthia_sas_0-1668723722807.png

 

  Some of your options (like OL and UL) did not make sense for ODS destinations because those are LISTING only options. Also, I put the text "Total Cases" on the last RBREAK row to make it clear what the number was under the CASEID cell. Most of the changes happen in the COMPUTE block for days.

Cynthia

Krysia24
Obsidian | Level 7

Thank you for providing the three different examples. Table 3 is exactly what I was looking to do, but having the other two examples with respective code helps me understand the proc report syntax a little more. I had attempted to use COMPUTE block at some point (in my trials and tribulations) but this paints a picture of just how dynamic COMPUTE can be. Thank you!

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 3 replies
  • 1715 views
  • 0 likes
  • 2 in conversation