The SAS Output Delivery System and reporting techniques

Want to insert a title page to an ODS PDF report...

Reply
N/A
Posts: 0

Want to insert a title page to an ODS PDF report...

Hi there,

I have a report generated by a macro call of PROC REPORT sending the final product to PDF via ODS PDF statements. Each page of the report is our agency logo with a table and some text. All works perfectly. I'm using V9.2 on windows XP.

Now I want to add a simple page of two big lines of text to the beginning of the report (like a title page) and eventually one in the middle (to note when the tables cease to be cancer incidence numbers and switch to mortality; which is in a more complicated version of the program not shown). I thought this would be easy using ODS PDF text="" statements and boosting the font size via a style, but although it wants to work, I'm getting some troubles with logos displaying on the title page, or improper page breaking after this title page. Any hints on a good way to do this?

Here is a simplified version of my code below. Any hints very welcome!

Thanks,
Ryan

-----------------------------------------------------------


%macro reportBC;

options nodate nonumber orientation=landscape;

ods pdf startpage=never pdftoc=1 bookmarklist=show style=ann_report file="British Columbia_&firstyr.-&lastyr..pdf";

ods escapechar="~";

* this part is what I want to make a blank page with the words Incidence Projections on it;
ods pdf startpage=on;
ods pdf startpage=now;
ods pdf startpage=never;
title1;

ods pdf text="~S={just=l font_weight=bold font_size=100pt}";
ods pdf text="~S={just=c font_weight=bold font_size=30pt}Cancer Incidence Projections";
ods pdf text="~S={just=c font_weight=bold font_size=30pt}&firstyr. to &lastyr.";

* loop here on the year;
* starting here, I want a report with 1 year of output per page with logo on page;
%do thisyear=&firstyr. %to &lastyr.;

ods pdf startpage=on;
ods pdf startpage=now;
ods pdf startpage=never;

title1 j=left h=8pt "~S={preimage='BCcancer_logo_black_small_test_JH.gif'}";

ods pdf text="~S={just=l font_weight=bold font_size=12pt}Estimated New Cancer Diagnoses for &thisyear. by Age at Diagnosis and Gender";

ods pdf text="~S={just=l font_weight=bold font_size=10pt}";
ods pdf text="~S={just=l font_weight=bold font_size=12pt}(&version.)";

ods pdf text="~S={just=l font_weight=bold font_size=10pt}";
ods pdf text="~S={just=l font_weight=bold font_size=12pt font_style=italic}British Columbia";

ods pdf text="~S={just=l font_weight=bold font_size=10pt}";
ods pdf text="~S={just=l font_size=9pt}Poisson regression models of the trend from 1998-2007 along with age, sex and region were fit for each cancer type. Mean rates for 2006-2007 replaced projected rates for Breast (female only) and prostate as extrapolation from recent trends was not feasible. Projections were obtained by multiplying the projected rates by population projections obtained from BC STATS. Row and column totals were obtained prior to rounding.";

ods pdf startpage=no;
ods proclabel "Incidence Projections: &thisyear.";

proc report data=bc_inc(where=(year=&thisyear.)) nowindows;

columns total_row cancer_order cancer_type ('Age at Diagnosis and Gender' M0_19 F0_19 M20_39 F20_39 M40_59 F40_59
M60_79 F60_79 M80 F80 MTot FTot Total);
define total_row / noprint display;
define cancer_order / noprint order;
define cancer_type / "Cancer Type" left display;
compute total_row;
if total_row in (1) then do;
call define(_col_,'style','style=[just=c font_weight=bold]');
call define(_row_,'style','style=[background=lightgrey font_weight=bold]');
end;
endcomp;
run;

ods pdf text="~S={just=l font_weight=bold font_size=10pt}";
ods pdf text="Population Projections (P.E.O.P.L.E &popv.) were obtained from BC STATS.";
ods pdf text="Prepared by Surveillance and Outcomes Unit, BC Cancer Agency (&repdate.)";
%end;

ods pdf close;

%mend reportBC;

%reportBC;
SAS Super FREQ
Posts: 8,868

Re: Want to insert a title page to an ODS PDF report...

Posted in reply to deleted_user
Hi:
If you're using SAS 9.2, then you might want to check out these papers that talk about using ODS LAYOUT. The first paper has an example of a title page:
http://support.sas.com/resources/papers/proceedings09/043-2009.pdf
http://support.sas.com/resources/papers/proceedings10/232-2010.pdf

FWIW, here's an older program (using PROC REPORT) to generate a title page and put an image in the document. I realize that you might not have a file called kermit2.jpg on your machine, but I left the pre-image in so you could see an alternate method.

cynthia
[pre]
%let firstyr = 2005;
%let lastyr = 2010;
title; footnote;

** change options so no page number on TITLE page;
options nodate nonumber center orientation=portrait;

data maketitle;
length tline $200;
tline = '~S={just=c font_weight=bold font_size=30pt}Cancer Incidence Projections~4n'; output;
tline = "~S={just=c font_weight=bold font_size=30pt}&firstyr. to &lastyr.~4n"; output;
run;

ods listing close;

ods pdf file='c:\temp\maketitle.pdf' startpage=yes;
ods escapechar='~';

proc report data=maketitle nowd noheader
style(report)={rules=none frame=void cellspacing=0};
title j=l '~S={preimage="c:\temp\kermit2.jpg"} ~_~_ ~6n ';
column tline;
define tline / display;
run;

options number pageno=1;
ods pdf;

** you want this page break;
proc print data=sashelp.class;
title2 'Print Title';
where age in ( 13, 14);
run;

ods pdf startpage=no;

** you do NOT want the page break for the proc REG output;
ods pdf select parameterestimates;
proc reg data=sashelp.class;
model age=height;
where age in ( 13, 14);
title2 'Reg Title';
run;
quit;

ods _all_ close;
[/pre]
N/A
Posts: 0

Re: Want to insert a title page to an ODS PDF report...

Posted in reply to Cynthia_sas
It works perfectly.

Thanks for the help and the links!

Ryan
Ask a Question
Discussion stats
  • 2 replies
  • 719 views
  • 0 likes
  • 2 in conversation