Thank you so much, Cynthia! I macro-ized your codes as below in case someone interested: title; footnote; options nodate nonumber center; proc sort data=sashelp.prdsale out=prdsale; by Country; run; data report; set prdsale nobs=last; by country; count=_n_; country=compress(country,'.'); length sitestr $1000; retain sitestr ' '; if first.country then if sitestr=' ' then sitestr=compress(country); else sitestr=trim(sitestr)||' '||compress(country); if last then do; call symput('sitestr',trim(sitestr)); end; run; %let sitett=%sysfunc(countw("&sitestr",' ')); %put sitestr=&sitestr sitett=&sitett; ods _all_ close; ods document name=work.TOCtest(write); %macro old; %do i=1 %to &sitett; %let site=%scan(&sitestr,&i); %put site=&site; ods proclabel ''; proc report data=report nowd spanrows contents="&site"; where country="&site"; column country region division PRODTYPE product quarter year month ACTUAL; define country / order; define region / order; define quarter / order; define year/ order; define month/display; define ACTUAL/sum format=dollar16.2; break before country/contents="Country=&site" page; break after country/summarize ; break after region / summarize; run; %end; %mend; %old; ods document close; ods listing; proc document name=work.TOCtest; list / levels=all; run; quit; ods listing close; ods pdf style=journal file='c:\temp\replay_old.pdf' ; proc document name=work.TOCtest; replay; run; quit; ods _all_ close; %macro new; proc document name=work.tocnew(write); make \testpath; dir \testpath#1; setlabel \testpath#1 "testing-Form Level"; dir; dir \testpath#1; %do i=1 %to &sitett; copy \work.TOCtest\Report#&i\Report#1\Report#1 to ^; %end; run; quit; ods listing; proc document name=work.tocnew; list / levels=all; run; quit; ods listing close; %mend; %new; ods pdf style=journal file='c:\temp\replay_new.pdf'; proc document name=work.tocnew; replay; run; quit; ods _all_ close;
... View more