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.
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.
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.";
I have a title like : "Results of the game - .
var1=game1 "
at each page.
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.
It stil does'nt work, I have a title like this one :
Results of the game - #byvar1
Thank you for your help.
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.
Yes it does, thank you.
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.
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.