BookmarkSubscribeRSS Feed
morglum
Quartz | Level 8

Hi everyone,

I would like to add a "group total" row, but only for groups that have more than one row.

 

For example, I would like to remove the total row for group 3 below.

 

 

How can I do this?

Thanks

 

 

data test;
  infile datalines dlm=',' dsd;
  input group user sales ;
return;
datalines;
1,1,1
1,2,2
1,3,5
2,4,3
2,5,3
2,6,4
3,7,4
;
run;

proc report data=test;
columns group user sales;
define group / group;
define user /display;
define sales / analysis sum;
break after group /summarize;

run; quit;

 

1 REPLY 1
Ksharp
Super User

Not in this way , But for Line statement.

 

 

data test;
  infile datalines dlm=',' dsd;
  input group user sales ;
return;
datalines;
1,1,1
1,2,2
1,3,5
2,4,3
2,5,3
2,6,4
3,7,4
;
run;
proc report data=test nowd;
columns group user sales;
define group / group;
define user /display;
define sales / analysis sum;
compute after group;
len=ifn(group=3,0,100);
text='Total:'||repeat(' ',40)||put(sales.sum,best10. -l);
line  text $varying100. len;
endcomp;
run; 

 

x.png

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 1707 views
  • 0 likes
  • 2 in conversation