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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.