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
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 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.
Ready to level-up your skills? Choose your own adventure.