Hi,
I have this sample dataset. What I want to happen on my proc report is that I on the row for the totals, I only want a value displayed for the column two and column one should not have a summary value. Is this possible? Please see script below and current and desired results. Thanks!
data test;
input nm $ one two;
datalines;
one 1 10
two 2 20
three 3 30
;
proc report data=test;
column nm one two ;
define nm / display;
define one / analysis sum;
define two / analysis sum;
rbreak after / summarize;
compute after;
if _break_ = '_RBREAK_' then do;
nm = 'Total';
end;
endcomp;
run;
quit;
Current Output
nm | one | two |
---|---|---|
one | 1 | 10 |
two | 2 | 20 |
three | 3 | 30 |
total | 6 | 60 |
Desired Output
nm | one | two |
---|---|---|
one | 1 | 10 |
two | 2 | 20 |
three | 3 | 30 |
total | 60 |
Hi:
If variable ONE has a usage of SUM ANALYSIS, it will be summarized during break processing. If variable ONE has a usage of DISPLAY, it will NOT be summarized at break processing. This is a simple fix and understanding the difference between DISPLAY and SUM is fundamental to how PROC REPORT decides which columns get summarized or not.
cynthia
Sure. Of course.
data test; input nm $ one two; datalines; one 1 10 two 2 20 three 3 30 ; run; option missing=''; proc report data=test nowd; column nm one two ; define nm / display; define one / analysis sum; define two / analysis sum; rbreak after / summarize; compute after; if _break_ = '_RBREAK_' then do; nm = 'Total'; call missing(one.sum); end; endcomp; run;
Ksharp
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.
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.