Hi. Cynthia.
I know that skill.
But the 'line' statement is more powerful and flexibility.So prefer to use 'line'.
And I also think useing only one proc report is hard to achieve this target,so using data step to pre-process origin data ,it will be better.
Be honest,it seems like a piece of cake, but it really waste my lots of time, which remind me never to neglect the little easy thing, maybe it is a big and tough problem.
Finally I complete it and get result what op want.
[pre]
data temp;
input region $ county $ ;
datalines;
1 100
1 200
1 200
2 300
2 300
;
run;
proc sort data=temp;
by region county;
run;
data temp;
set temp end=last;
by region;
_region=region;
_county=county;
if county ne lag(county) then do; break+1; total_county=0; end;
if region ne lag(region) then total_region=0;
if last.region then region_len=20;
else region_len=0;
if last then grand_len=20;
else grand_len=0;
total_county+1; str_county=cats('county total: ',total_county);
total_region+1; str_region=cats('region total: ',total_region);
total_grand+1; str_grand=cats('grand total: ',total_grand);
run;
ods pdf file='c:\total.pdf' style=sasweb;
proc report data=temp nowd out=test;
column region county _region _county break region_len grand_len str_county str_region str_grand;
define region /order width=10 noprint;
define county /order width=10 noprint;
define _region/display;
define _county /display;
define break / order noprint;
define region_len/ noprint;
define grand_len/ noprint;
define str_county/ noprint;
define str_region/noprint;
define str_grand/noprint;
compute str_grand;
if _break_ eq ' ' then do;
_str_county=str_county;
_str_region=str_region;
_str_grand=str_grand;
end;
endcomp;
compute after break;
line _str_county $20.;
line _str_region $varying. region_len.sum;
line _str_grand $varying. grand_len.sum;
endcomp;
break after break /page;
run;
ods pdf close;
[/pre]
Ksharp
... View more