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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.