BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lovedieer
Calcite | Level 5

I using proc report to create 10 reports for each year.

sample codes:

ods pdf file='startpage.pdf' notoc  startpage=no;

proc report data=grain_production nowindows;

by year;

   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?

1 ACCEPTED SOLUTION

Accepted Solutions
lovedieer
Calcite | Level 5

Hi, Cynthia:

THis is really working well. Thanks very much.

View solution in original post

5 REPLIES 5
Cynthia_sas
SAS Super FREQ

Hi:

  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.

Cynthia

proc sort data=sashelp.class out=class;

by age name;

run;

   

options nobyline nodate nonumber;

   

ods pdf file='c:\temp\simulate_by_title.pdf' startpage=no;

  

title 'Top of Page';

proc report data=class nowd;

  by age;

  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.;

  endcomp;

run;

ods pdf close;


Proc_Report_pseudo_title.png
lovedieer
Calcite | Level 5

Hi, Cynthia:

THis is really working well. Thanks very much.

KGS
Calcite | Level 5 KGS
Calcite | Level 5

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.

Cynthia_sas
SAS Super FREQ
Hi:
Did you try the posted code? When I change the destination from PDF to RTF, the posted code works for me. It is not a title from a SAS title statement, but it is the BY group information in a "pseudo-title". You don't have to put the BY group information where I do in the example, but you can put any text string in the COMPUTE block you want.

cynthia
KGS
Calcite | Level 5 KGS
Calcite | Level 5

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 ;

%REPORT1(B02,B02TOT,'SPECIAL');

%REPORT2(B02,B02SUP,'SPECIAL');

%REPORT3(B02,B02DEMD,'SPECIAL');

%REPORT4(B02,B02DEMF,'SPECIAL');

%REPORT5(B02,B02LOAD,'SPECIAL');

%REPORT6(B02,B02FDEM,'SPECIAL');

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.

Thanks.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 4816 views
  • 3 likes
  • 3 in conversation