BookmarkSubscribeRSS Feed
hari1109
Fluorite | Level 6
Thank you in advance..

I have a dataset that has more than 500 records and i have to produce a pdf file output
out of it using ods pdf destination in sas enterprise guide but the titles are appearing in every page which i don't want. I have titles with macro variables in it and they should appear in only first page. i tried using compute block with _page_ but by doing so i am getting line statements in all pdf pages. Is there any way to restrict titles to first page?
Thank you.
21 REPLIES 21
Ksharp
Super User
Hi.
You can use a " proc print " before " proc report " .



Ksharp
Cynthia_sas
SAS Super FREQ
Hi:
Or, you could use two PROC REPORT steps. The bottom line, is that you have to figure out how many obs "fit" on the first page. For the default style, using SASHELP.SHOES, I can get 33 obs on the first page with 1/2 inch margins at the top and bottom of the page:
[pre]
options orientation=portrait topmargin=.5in bottommargin=.5in nodate nonumber;
title; footnote;
ods pdf file='c:\temp\onlyfirst.pdf' notoc;

proc report data=sashelp.shoes(firstobs=1 obs=33) nowd;
column region subsidiary product sales inventory returns;
title 'Title on First Page Only';
run;

title; /* clears previous title */
proc report data=sashelp.shoes(firstobs=34 obs=max) nowd;
column region subsidiary product sales inventory returns;
run;

ods _all_ close;
[/pre]

Since the TITLE statement can only be cleared between procedure steps, the second proc report picks up displaying observations with firstobs=34, but AFTER the title has been cleared with a null TITLE statement.

cynthia
polingjw
Quartz | Level 8
Of course, this solution assumes that you have no summary lines in the report. When you have summary lines in the report, splitting the dataset into two parts does not work. I have also run into this problem and I never found an acceptable alternative. See http://support.sas.com/forums/thread.jspa?messageID=40487鸧.
Cynthia_sas
SAS Super FREQ
You're right -- if you need any kind of summary information that includes what was on the first "page" then you have to do some fiddling to make it work -- but that's the difference between a word processor (that allows you to treat the first page differently from the other pages) and a report generator -- that treats the titles and footnotes as "global" statements which apply to the whole report.

You can't analyze 10 years of census data in Word, but you can get a separate title on the first page. You CAN analyze and report on 10 years of census data in SAS -- but by default all pages on the report get the same title. SAS isn't a Word processor -- SAS, using ODS, can create Word processor readable documents -- but with limits.

cynthia
SASFiddler
Calcite | Level 5

Print with title and report without title:

 

ods ...
title2 'AAAAAA';

 

proc print data=...;
var ...;
label ...
run;

title2 '';
proc report data=...;
column ...;
by ...;
DEFINE ...;
format ...;
run;
ods ...

santos_stats
Calcite | Level 5

Just Signed up to Thank Cynthia. It has been a hell of a problem for me before I visited this forum.

Thank You again Cynthia.

SASdevAnneMarie
Barite | Level 11

Hello,

 

I would like to have ods rtf with title only in the fisrt page.

I tried your code (for pdf), I have the title on the 2 first pages:

 

ods pdf file='\\XXXXXXXX\TEST\onlyfirst.pdf' notoc;

proc report data=sashelp.shoes(firstobs=1 obs=33) nowd;
column region subsidiary product sales inventory returns;
title 'Title on First Page Only';
run;

title; /* clears previous title */
proc report data=sashelp.shoes(firstobs=34 obs=max) nowd;
column region subsidiary product sales inventory returns;
run;

ods _all_ close;

 

Maybe you know some option to do that?

 

Thank you very much!

 

 

Cynthia_sas
SAS Super FREQ

Hi:

  I do not have that experience with your code, SASHELP.SHOES and ODS PDF, as shown below:

only_first.png

 

Without knowing your orientation and margin options, I could not completely replicate your experience, but I used the options shown in the above screen shot and the title on page 1 worked for me. If you use the SAME options and orientation and margins and still get the title starting on page 2, then you might want to open a track with Tech Support for deeper investigation about your system settings.

 

Cynthia

SASdevAnneMarie
Barite | Level 11

Thank you Cynthia.

My problem is that I want the landscape format for my report.

This code does not work with landscape option.

Maybe you have some idea for additional option with lanscape format please. My code is:

options orientation=landscape topmargin=.5in bottommargin=.5in nodate nonumber;

title; footnote;
ods rtf file='\\XXXXXXXXXXXXXX\4. Résultats excel\3. Publipostage\TEST\onlyfirst.doc' ;
proc report data=sashelp.shoes(firstobs=1 obs=33) nowd;
column region subsidiary product sales inventory returns;
title 'Title on First Page Only';
run;

title;
proc report data=sashelp.shoes(firstobs=34 obs=max) nowd;
column region subsidiary product sales inventory returns;
run;

ods _all_ close;

SASFiddler
Calcite | Level 5
ods pdf file='\\XXXXXXXXXX\onlyfirst.pdf' notoc;
options NOBYLINE;
proc report data=sashelp.shoes nowd;
column region subsidiary product sales inventory returns;
by Region Subsidiary;
title 'Title on First Page Only "#BYLINE"';
run;

ods _all_ close;



That may help some.


SASdevAnneMarie
Barite | Level 11

Hello,

 

Thank you for the code.

Unfortunately,

I have the same proble: the title on the ALL pages:

My programme is:

 

ods pdf file='\\XXXXXX\TEST\onlyfirst.pdf' notoc;
options NOBYLINE;
proc report data=sashelp.shoes nowd;
column region subsidiary product sales inventory returns;
by Region Subsidiary;
title 'Title on First Page Only "#BYLINE"';
run;

ods _all_ close;

SASFiddler
Calcite | Level 5
You could use an additional variable to indicate the first page;


ods pdf file='\\helsinki1.hki.local\kymp\Maankäyttö\Tutkimukset_ja_selvitykset\Liikennetutkimus\Helmi\Liikennelaskennat\onlyfirst.pdf' notoc;
options NOBYLINE;
proc report data=sashelp.shoes nowd;
column region subsidiary product sales inventory returns;
by Region Subsidiary;
title 'Title on First Page Only "#BYLINE"';
run;
options BYLINE;

ods _all_ close;


SASdevAnneMarie
Barite | Level 11

Thank you, still does not work for me, I have the titles on ALL pages:

 

ods pdf file='\\XXXXXX\4. Résultats excel\3. Publipostage\TEST\onlyfirst.pdf' notoc;
options NOBYLINE;
proc report data=sashelp.shoes nowd;
column region subsidiary product sales inventory returns;
by Region Subsidiary;
title 'Title on First Page Only "#BYLINE"';
run;
options BYLINE;

ods _all_ close;

SASFiddler
Calcite | Level 5
ods pdf file='\\XXXXXXXXXXXXXXXX\onlyfirst.pdf' notoc;

data test;
set sashelp.shoes;
rownum=_n_;
run;
data test1;
set test;
if rownum<34;
run;
data test2;
set test;
if rownum>33;
run;
proc report data=test1 nowd;
column region subsidiary product sales inventory returns;
title 'Title on First Page Only';
run;
proc report data=test2 nowd;
column region subsidiary product sales inventory returns;
title;
run;


ods _all_ close;


sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 21 replies
  • 5596 views
  • 1 like
  • 8 in conversation