09-05-2014 04:22 PM
I using proc report to create 10 reports for each year.
ods pdf file='startpage.pdf' notoc startpage=no;
proc report data=grain_production nowindows;
column country type kilotons;
define country / group width=14 format=$cntry.;
define type / group 'Type of Grain';
define kilotons / format=comma12.;
title 'Leading Grain-Producing Countries';
title2 'for #byval(year)';run;
when i use the startpage=no, all the results go to same page like i expected, but the title only showed at the top of each page, not for each tables. anyway to make the title for each year's table?
09-06-2014 12:15 AM
As far as PDF is concerned a document has 1 title at the top of the page. If you use STARTPAGE=NO, then PDF uses the first title for the first BY group at the top of the page and then STARTPAGE=NO tells SAS that the other procedures get put somewhere OTHER than the top of the page to start. Since the procedure isn't starting at the top of the page, the assumption is that you do NOT want the SAS title in the middle of the page.
One way to work around it is to use ODS TEXT= between multiple runs of your procedure like:
ods pdf file=...
ods text= ... ; /* for by group 1 */
** proc for by group 1;
ods text=...; /* for by group 2 */
** proc for by group 2;
ods text= ... ; /*for by group 3 */
** proc for by group 3;
ods pdf close;
Or, specifically with PROC REPORT, use the COMPUTE BEFORE to write some custom text for each BY group. You should be able to run this code. It produced the attached results.
proc sort data=sashelp.class out=class;
by age name;
options nobyline nodate nonumber;
ods pdf file='c:\temp\simulate_by_title.pdf' startpage=no;
title 'Top of Page';
proc report data=class nowd;
column age name sex height weight;
define age / order noprint;
compute before _page_;
length pgline $10;
pgline = catx(' ',"Age =",age);
line "Report for Students";
line pgline $10.;
ods pdf close;
02-16-2016 06:14 PM
I have a similar problem, in that in SAS Enterprise Guide I am writing out a series of reports in macros to ODS RTF and I am losing the titles on each PROC REPORT except at teh top of the page. I am using STARTPAGE=NO and KEEPN, but would like to have the titles of each PROC REPORT show up. Any suggestions? Thanks.
02-16-2016 11:25 PM
02-17-2016 09:41 AM
No, Cynthia, I didn't try the posted code, because I'm running six macros to produce six separate reports I'm putting into one output file that the end users want on as few pages as possible; the first attempt had page breaks between each report. Since they are separate reports (separate data sources and all), using a BY statement won't really work.
Here's an example of the code:
ODS RTF FILE='/data/mk/eqpmgmt/fleet_reports/B02.rtf' STARTPAGE=NO KEEPN ;
ODS RTF CLOSE ;
Each report macro is a separate PROC REPORT with its own title, but the title is only displaying on the first report on the page.