DATA Step, Macro, Functions and more

Title in PDF file

Accepted Solution Solved
Reply
Contributor
Posts: 21
Accepted Solution

Title in PDF file

[ Edited ]

Hi, I would like to insert a title in each page of my PDF file depending on values from a variable, I tried this :

PROC SORT DATA=tab;
BY var1;
RUN;

ODS PDF FILE="C:\Users\User\Desktop\File.pdf" STYLE=PEARL STARTPAGE=BYGROUP;
title CATX(" - ","Results of the game", var1);
PROC PRINT DATA=tab (FIRSTOBS=2) sumlabel="Totals" label NOOBS;
VAR var2-var5;
BY var1;
sum var2-var4;
RUN;
ODS PDF CLOSE;


However I have literally this title :

CATX(" - ","Results of the game", var1)

instead of :

Results of the game - game 1

(For the first game for example)

 

Thanks for your help.


Accepted Solutions
Solution
‎01-09-2018 05:08 AM
Super User
Super User
Posts: 9,222

Re: Title in PDF file

It should work, try:

options nobyline;

ods pdf file="s:\temp\file.pdf" style=pearl startpage=bygroup;

proc sort data=sashelp.class out=class;
  by sex;
run;

proc print data=class (firstobs=2) sumlabel="Totals" label noobs;
  var _all_;
  by sex;
  title "Results of the game - #byval1";
run;
ods pdf close;

Oh, and "it doesn't work" - doesn't help.  Post your code in full and test data which shows the operation as a datastep.

View solution in original post


All Replies
PROC Star
Posts: 1,190

Re: Title in PDF file

You can not use functions in a title statement like that.

 

Do somethind like this

 

data _null_;
	MyTitle=CATX(" - ","Results of the game", var1);
	call symputx("MyTitle", MyTitle);
run;

title "&MyTitle.";
Contributor
Posts: 21

Re: Title in PDF file

I have a title like : "Results of the game - .

                                                                

                                  var1=game1  "

at each page.

 

Super User
Super User
Posts: 9,222

Re: Title in PDF file

Use By Grouping - it is a key feature of SAS and will make your coding life much easier (and not coding in upper case or mixed case will help my eyesight!!!):

ods pdf file="c:\users\user\desktop\file.pdf" style=pearl startpage=bygroup;
proc print data=tab (firstobs=2) sumlabel="Totals" label noobs;
  var var2-var5;
  by var1;
  title "Results of the game - #byvar1";
  sum var2-var4;
run;
ods pdf close;

Note specifically the #byvar1, you could also use #byval1.

Contributor
Posts: 21

Re: Title in PDF file

It stil does'nt work, I have a title like this one :

Results of the game - #byvar1

Thank you for your help.

Solution
‎01-09-2018 05:08 AM
Super User
Super User
Posts: 9,222

Re: Title in PDF file

It should work, try:

options nobyline;

ods pdf file="s:\temp\file.pdf" style=pearl startpage=bygroup;

proc sort data=sashelp.class out=class;
  by sex;
run;

proc print data=class (firstobs=2) sumlabel="Totals" label noobs;
  var _all_;
  by sex;
  title "Results of the game - #byval1";
run;
ods pdf close;

Oh, and "it doesn't work" - doesn't help.  Post your code in full and test data which shows the operation as a datastep.

Contributor
Posts: 21

Re: Title in PDF file

Yes it does, thank you.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 158 views
  • 0 likes
  • 3 in conversation