Is it possible to suppress the summary line when it equals the grouping result (>> Wien)?
Thank you
data t1;
land='F'; city='Paris'; value=100; output;
land='F'; city='Lyon'; value=200; output;
land='D'; city='Berlin'; value=100; output;
land='D'; city='Hamburg'; value=200; output;
land='A'; city='Wien'; value=100; output;
run;
proc report data=t1;
column land city value;
define land / group;
define city / group;
define value / sum;
break after land / summarize;
run;
Result:
land city value
A Wien 100
A 100 >> I would like to suppress this row
D Berlin 100
Hamburg 200
D 300
F Lyon 200
Paris 100
F 300
I'm not good with PROC REPORT, but this seems to work.
data t1;
length land $8;
land='F'; city='Paris'; value=100; output;
land='F'; city='Lyon'; value=200; output;
land='D'; city='Berlin'; value=100; output;
land='D'; city='Hamburg'; value=200; output;
land='A'; city='Wien'; value=100; output;
run;
options missing=' ';
proc report data=t1 nowd list headline;
column land city value value=n;
define land / group;
define city / group;
define value / sum;
define n / n noprint;
break after land / summarize suppress;
compute before land;
rland = land;
endcomp;
compute after land;
*rc = seenum(value.sum);
*rc = seenum(n);
msg = ' ';
if n gt 1 then do;
land = catx(' ',rland,'Total');
l = 1;
end;
else do;
value.sum=.;
l=0;
end;
line msg $varying1. l;
endcomp;
run;
I'm not good with PROC REPORT, but this seems to work.
data t1;
length land $8;
land='F'; city='Paris'; value=100; output;
land='F'; city='Lyon'; value=200; output;
land='D'; city='Berlin'; value=100; output;
land='D'; city='Hamburg'; value=200; output;
land='A'; city='Wien'; value=100; output;
run;
options missing=' ';
proc report data=t1 nowd list headline;
column land city value value=n;
define land / group;
define city / group;
define value / sum;
define n / n noprint;
break after land / summarize suppress;
compute before land;
rland = land;
endcomp;
compute after land;
*rc = seenum(value.sum);
*rc = seenum(n);
msg = ' ';
if n gt 1 then do;
land = catx(' ',rland,'Total');
l = 1;
end;
else do;
value.sum=.;
l=0;
end;
line msg $varying1. l;
endcomp;
run;
Null's code is great, I almost forgot this skill. Thanks Null to remind me .
data t1; land='F'; city='Paris'; value=100; output; land='F'; city='Lyon'; value=200; output; land='D'; city='Berlin'; value=100; output; land='D'; city='Hamburg'; value=200; output; land='A'; city='Wien'; value=100; output; run; options missing=' '; proc report data=t1 nowd; column land city value; define land / group; define city / group; define value / sum; compute value; if land='A' and _break_='land' then call missing(land,city,value.sum,_break_); endcomp; break after land / summarize; 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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.