BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi all,

I produce statistical tables using ODS RTF and next post-processing. However, my statistical table is spanned on many pages. I had a footer at the bottom of the table using the COMPUTE AFTER; ... ENDCOMP; but my footer only appears at the end of the table (i.e., at the end of the doc). What I would like is: my footer appears on the bottom of the table IN EACH PAGE of the RTF document.

Do you know any means which could help me?

Thanks so much for your help,
Best regards,

Violaine
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi, Violaine:
In SAS 9.1.3, when you use RTF, paging and page breaks are managed by the word processor that renders the RTF document for viewing. This means that PROC REPORT's COMPUTE AFTER _PAGE_ generally is ignored for RTF, PDF and HTML and only works in LISTING (where the page size is respected).
In SAS 9.2, there is a new "flavor" of RTF, called TAGSETS.RTF that respects vertical measurement, and thus, would work with COMPUTE AFTER _PAGE_.
Your only choices in SAS 9.1.3 are to:
1) put a footnote on the bottom of every page where the footnote was a line
2) post-process the RTF file -- search for the indicator of a page end and insert the line using RTF control strings -- then on the last page, when you do find your COMPUTE AFTER _PAGE_, you would NOT change the last page.
3) possibly consider breaking your big table down into smaller groups -- perhaps with BY group processing
4) find the observations that occurs at the bottom of every page and then in a compute block, use RTF control strings to put an underline at the bottom of that obs (this is VERY tricky, because it assumes that the margins/font/etc that you use when you find out what obs is at the bottom of the page are the same margins/fonts/etc that are going to be used when the FINAL output is rendered.
5) make a "fake" page break variable and then do a compute after THAT variable and use your RTF control string
To accomplish #1, review the postings here:
http://support.sas.com/forums/thread.jspa?messageID=2824ଈ

To accomplish #1, #4 or #5, see the program below.

cynthia
[pre]
options nodate nonumber orientation=landscape;

%let t3=%str(Table SAF 7.2);
%let t4=%str(Listing of Serious Adverse Events);
%let t5=%str(Population: Safety);

%let f2=%str(+: Relative to the date of the first application.);
%let f3=%str(@: Cont=Continuing, Res=Resolved no residual effects, ResR=Resolved with residual effects, Lost=Lost to follow up.);
%let f4=%str(*: Temp=Study drug regimen reduced or discontinued temporarily, Perm=Study drug discontinued permanently.);
%let f5=%str(†: Tx=Began and/or changed concurrent therapy, Hosp=Inpatient Hospitalization/prolongation of hospitalization,);
%let f6=%str( NonTx=Non drug therapy, Other=Other (explained in comments section).);

title1 j=l font='Arial' h=10.1pt
%nrstr("Pharma R&D")
j=r font='Arial' h=10.1pt
"%sysfunc(datetime(), datetime16.)";
title2 j=l font='Arial' h=10.1pt
"Protocol XXX"
j=r font='Arial' h=10.1pt "Page ^{thispage} of ^{lastpage}";

title3 j=c font='Arial' h=10.1pt "&t3.";
title4 j=c font='Arial' h=10.1pt "&t4.";
title5 j=c font='Arial' h=10.1pt "&t5.";

**make sure there is a SPACE between the 1 and the quote;
** in the footnote below;
footnote j=l font='Arial' h=10.1pt
"^S={protectspecialchars=off "
"pretext='\brdrt\brdrs\brdrw1 '}"
"\~";
footnote2 j=l font='Arial' h=10.1pt
"&f2.";
footnote3 j=l font='Arial' h=10.1pt
"&f3.";
footnote4 j=l font='Arial' h=10.1pt
"&f4.";
footnote5 j=l font='Arial' h=10.1pt
"&f5";
footnote6 j=l font='Arial' h=10.1pt
"&f6.";

** note that line above footnote does NOT work for PDF or HTML;
** and the ^{thispage} or ^{lastpage} do not work for HTML;

ods listing close;

ods rtf file='c:\temp\line_detailA.rtf' style=journal;
ods escapechar='^';
title 'a) Proc Report with Line in Footnote';
proc report data=sashelp.shoes nowd
style(report)={rules=groups frame=hsides cellspacing=0 cellpadding=2pt};
where region in ('Western Europe', 'Canada');
column region product sales;
define region /order noprint;
define product /order 'Region/Product'
style(header)={just=l}
style(column)={indent=20 cellwidth=1.5in};
define sales /sum;
break after region / page;
compute before region /
style={just=l font_weight=bold};
line Region $25.;
endcomp;
compute before _page_ /
style={just=l font_weight=bold};
line 'From Compute Before _PAGE_';
endcomp;
compute after _page_ /
style={just=l font_weight=bold};
line 'From Compute AFTER _PAGE_';
endcomp;
run;
ods _all_ close;


ods rtf file='c:\temp\line_detailB.rtf' style=journal;
ods escapechar='^';

title; footnote;
footnote1 j=l font='Arial' h=10.1pt
"&f2.";
footnote2 j=l font='Arial' h=10.1pt
"&f3.";
footnote3 j=l font='Arial' h=10.1pt
"&f4.";
footnote4 j=l font='Arial' h=10.1pt
"&f5";
footnote5 j=l font='Arial' h=10.1pt
"&f6.";

title 'b) Proc Report without Line on Last Obs on each page';
proc report data=sashelp.shoes nowd
style(report)={rules=groups frame=hsides cellspacing=0 cellpadding=2pt};
where region in ('Western Europe', 'Canada');
column region product sales;
define region /order noprint;
define product /order 'Region/Product'
style(header)={just=l}
style(column)={indent=20 cellwidth=1.5in};
define sales /sum;
break after region / page;
compute before region /
style={just=l font_weight=bold};
line Region $25.;
endcomp;
compute before _page_ /
style={just=l font_weight=bold};
line 'From Compute Before _PAGE_';
endcomp;
compute after _page_ /
style={just=l font_weight=bold};
line 'From Compute AFTER _PAGE_';
endcomp;
compute sales;
** find the last value on every page and then;
** hard code the border for the last row on the page;
** but this is VERY tricky -- and the table can change;
** if you change the margins in the word processor.;
if sales.sum in (29435, 977, 141287) then
call define(_ROW_,'style',
'style={protectspecialchars=off posttext="\brdrb\brdrs\brdrw1"}');
endcomp;
run;


** C) different approach: FAKE page break variable;
proc sort data=sashelp.shoes;
by region product;
run;

data newshoes;
set sashelp.shoes;
retain pgbr;
where region in ('Western Europe', 'Canada');
if _n_ = 1 then pgbr = ' ';
if region = 'Canada' and
product in ('Boot', "Men's Casual",
"Men's Dress", 'Sandal', 'Slipper') then do;
pgbr = 'C1';
end;
else if region = 'Western Europe' and
product in ('Boot', "Men's Casual",
"Men's Dress") then do;
pgbr = 'W1';
end;
else if region = 'Western Europe' and
product in ('Sandal', "Slipper",
"Sport Shoe") then do;
pgbr = 'W2';
end;
else do;
if region = 'Canada' then pgbr = 'C2';
else if region = 'Western Europe' then pgbr = 'W3';
end;
run;

ods _all_ close;


ods rtf file='c:\temp\line_detailC.rtf' style=journal;
ods escapechar='^';

title; footnote;
footnote1 j=l font='Arial' h=10.1pt
"&f2.";
footnote2 j=l font='Arial' h=10.1pt
"&f3.";
footnote3 j=l font='Arial' h=10.1pt
"&f4.";
footnote4 j=l font='Arial' h=10.1pt
"&f5";
footnote5 j=l font='Arial' h=10.1pt
"&f6.";

title 'c) Proc Report with "FAKE" page variable';
proc report data=newshoes nowd
style(report)={rules=groups frame=hsides cellspacing=0 cellpadding=2pt};
column region pgbr product sales;

define region /order noprint;
define pgbr / order noprint;

define product /order 'Region/Product'
style(header)={just=l}
style(column)={indent=20 cellwidth=1.5in};
define sales /sum;

compute before region /
style={just=l font_weight=bold};
line Region $25.;
endcomp;
compute before _page_ /
style={just=l font_weight=bold};
line 'From Compute Before _PAGE_';
endcomp;
compute after pgbr /
style={just=l font_weight=bold};
line 'From Compute AFTER PGBR (fake page break variable)';
endcomp;
break after pgbr / page;
run;
ods _all_ close;
title;
footnote;

[/pre]

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 2130 views
  • 2 likes
  • 2 in conversation