BookmarkSubscribeRSS Feed
scb
Obsidian | Level 7 scb
Obsidian | Level 7

I tried to put the report title for each of the proc report, but it seems that the different titles just did not appear at the right place.  Anyone can help? Thanks.

 

DATA T1;
SET SASHELP.CARS;
IF ORIGIN EQ 'Asia' AND TYPE EQ 'SUV';
KEEP MAKE MODEL TYPE ORIGIN;
RUN;

 

DATA T2;
SET SASHELP.CARS;
IF MAKE EQ 'Acura';
KEEP MAKE MODEL TYPE ORIGIN INVOICE;
RUN;

 

DATA T3;
SET SASHELP.CARS;
IF INVOICE GE 100000;
KEEP MAKE MODEL TYPE ORIGIN INVOICE;
RUN;

 

%LET OUTPATH = C:\test\test.PDF;
OPTIONS ORIENTATION=LANDSCAPE PAPERSIZE=A5;
OPTIONS NODATE;
OPTIONS LINESIZE=130 PAGESIZE=60 CENTER;
ODS PDF FILE="&OUTPATH" STARTPAGE=NO;


PROC REPORT DATA=T1;
TITLE1 'SUV from Asia';
COLUMN MAKE MODEL TYPE ORIGIN;
DEFINE MAKE / DISPLAY 'Brand';
DEFINE MODEL / DISPLAY 'Model';
DEFINE TYPE / DISPLAY 'Type';
DEFINE ORIGIN / DISPLAY 'Origin';
RUN;


PROC REPORT DATA=T2;
TITLE2 'Car Price by Acura';
COLUMN MAKE MODEL TYPE ORIGIN;
DEFINE MAKE / DISPLAY 'Brand';
DEFINE MODEL / DISPLAY 'Model';
DEFINE TYPE / DISPLAY 'Type';
DEFINE ORIGIN / DISPLAY 'Origin';
DEFINE INVOICE / DISPLAY 'Price';
RUN;

PROC REPORT DATA=T3;
TITLE3 'Car Price over 100k';
COLUMN MAKE MODEL TYPE ORIGIN INVOICE;
DEFINE MAKE / DISPLAY 'Brand';
DEFINE MODEL / DISPLAY 'Model';
DEFINE TYPE / DISPLAY 'Type';
DEFINE ORIGIN / DISPLAY 'Origin';
DEFINE INVOICE / DISPLAY 'Price';
RUN;

ODS PDF CLOSE;
ODS LISTING;

5 REPLIES 5
yabwon
Onyx | Level 15

What do you mean by "but it seems that the different titles just did not appear at the right place."?

What are your expectations? Do you want to have text "SUV from Asia" before table one, and then _only_ the 'Car Price by Acura' before table two?

 

B-)

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



scb
Obsidian | Level 7 scb
Obsidian | Level 7
Yes, is it possible?
yabwon
Onyx | Level 15

Try this:

DATA T1;
SET SASHELP.CARS;
IF ORIGIN EQ 'Asia' AND TYPE EQ 'SUV';
KEEP MAKE MODEL TYPE ORIGIN;
RUN;

 

DATA T2;
SET SASHELP.CARS;
IF MAKE EQ 'Acura';
KEEP MAKE MODEL TYPE ORIGIN INVOICE;
RUN;

 

DATA T3;
SET SASHELP.CARS;
IF INVOICE GE 100000;
KEEP MAKE MODEL TYPE ORIGIN INVOICE;
RUN;

 

%LET OUTPATH = %sysfunc(pathname(work))\test.PDF;
OPTIONS ORIENTATION=LANDSCAPE PAPERSIZE=A5;
OPTIONS NODATE;
OPTIONS LINESIZE=130 PAGESIZE=60 CENTER;
ODS PDF FILE="&OUTPATH" STARTPAGE=NO;


PROC REPORT DATA=T1;
TITLE 'SUV from Asia';
COLUMN MAKE MODEL TYPE ORIGIN;
DEFINE MAKE / DISPLAY 'Brand';
DEFINE MODEL / DISPLAY 'Model';
DEFINE TYPE / DISPLAY 'Type';
DEFINE ORIGIN / DISPLAY 'Origin';
RUN;

ODS PDF STARTPAGE=NOW;
PROC REPORT DATA=T2;
TITLE 'Car Price by Acura';
COLUMN MAKE MODEL TYPE ORIGIN;
DEFINE MAKE / DISPLAY 'Brand';
DEFINE MODEL / DISPLAY 'Model';
DEFINE TYPE / DISPLAY 'Type';
DEFINE ORIGIN / DISPLAY 'Origin';
DEFINE INVOICE / DISPLAY 'Price';
RUN;

ODS PDF STARTPAGE=NOW;
PROC REPORT DATA=T3;
TITLE 'Car Price over 100k';
COLUMN MAKE MODEL TYPE ORIGIN INVOICE;
DEFINE MAKE / DISPLAY 'Brand';
DEFINE MODEL / DISPLAY 'Model';
DEFINE TYPE / DISPLAY 'Type';
DEFINE ORIGIN / DISPLAY 'Origin';
DEFINE INVOICE / DISPLAY 'Price';
RUN;

ODS PDF CLOSE;
ODS LISTING;

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

One more thing, 

may be you need "startpage=now" option?

ODS PDF STARTPAGE=NOW;
PROC REPORT DATA=T2;
TITLE2 'Car Price by Acura';
...
RUN;

ODS PDF STARTPAGE=NOW;
PROC REPORT DATA=T3;
TITLE3 'Car Price over 100k';
...
RUN;

 

B-)

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Cynthia_sas
SAS Super FREQ
Hi:
Just a quick observation. Option like LINESIZE and PAGESIZE are ignored by ODS PDF. Your PAPERSIZE, ORIENTATION and NODATE and CENTER options will be respected by ODS PDF.
No need really for your 3 DATA steps. You can use WHERE and KEEP= dataset options directly in PROC REPORT.
However, with STARTPAGE=NO, if you have a title statement and a report starts in the middle of the page, the SAS title is NOT used. So, for example, your 2nd and 3rd reports would possibly fit on one page. However, with STARTPAGE=NO the titles will not show as you envision. For PDF output, SAS titles can ONLY go at the TOP of the page, SAS titles cannot be inserted into the middle of the page. If you need extra text inserted between outputs when you have STARTPAGE=NO, then you need to use ODS TEXT statements. By default, every PROC REPORT would normally start a new page, in which case, the TITLE statements would work correctly. (Although, I'm not sure you are using TITLE1, TITLE2 and TITLE3 correctly. It seems to me that you really want TITLE1 for all 3 reports.)

Cynthia

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
  • 5 replies
  • 1750 views
  • 3 likes
  • 3 in conversation