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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

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.";
Num19
Calcite | Level 5

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

                                                                

                                  var1=game1  "

at each page.

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Num19
Calcite | Level 5

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

Results of the game - #byvar1

Thank you for your help.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Num19
Calcite | Level 5

Yes it does, thank you.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 972 views
  • 0 likes
  • 3 in conversation