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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.