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
SAS Super FREQ

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
SAS Super FREQ

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!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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