Hello,
I would like to add Page X of Y to my PDF output. I noticed that the ""^{lastpage}"" command in "Page ^{thispage} of ^{lastpage}" does not output my graph as expected. When I use the code below, only the first page has a graph, but the rest of the pages are blank. This is seen in the attached output - editable_pdf.pdf. There are 6 fuel types, so there should be 6 pages of graphs.
proc sort data = sashelp.gas out = gas;
by fuel;
run;
options printerpath=pdf;
options nonumber nodate;
goptions reset = all;
ods escapechar="^";
title "Page ^{thispage} of ^{lastpage}";
ods graphics / reset = all;
ods pdf file = "C:\vector\output\editable_pdf.pdf" nogtitle;
proc sgplot data = gas;
by fuel;
styleattrs datalinepatterns=(solid);
loess y=nox x=eqratio;
run;
ods pdf close;
When I calculate the pages numbers with a macro (as shown below) and use that number instead of ""^{lastpage}"" , then the graphs output as expected.
proc sort data = sashelp.gas out = gas;
by fuel;
run;
* Working out total number of pages with macro;
proc sql;
select strip(put(count(distinct fuel), best.)) into: totpage
from gas;
quit;
options printerpath=pdf;
options nonumber nodate;
goptions reset = all;
ods escapechar="^";
title "Page ^{thispage} of &totpage";
ods graphics / reset = all;
ods pdf file = "C:\vector\output\editable_pdf2.pdf" nogtitle;
proc sgplot data = gas;
by fuel;
styleattrs datalinepatterns=(solid);
loess y=nox x=eqratio;
run;
ods pdf close;
Does anyone know why using Page ^{thispage} of ^{lastpage} does not produce the graph properly?
Many thanks,
Kriss
Hi:
Look at this Tech Support note: http://support.sas.com/kb/34/573.html. It has the workaround of using &totpage, as you show. This was an interaction between graphs and {lastpage} that was reported in SAS 9.2 and doesn't look like it is fixed yet.
Cynthia
Update (5/9/2018): there was a defect reported on this issue. It appears that the issue is fixed in 9.4 M5 release. So if you are experiencing this problem, then upgrading to 9.4M5 should fix the issue.
Hi Kriss,
"nogtitle" with combination title "page ^{thispage} of ^{lastpage}" has some reltation.
If you remove the "nogtitle" option in ODS PDF then graph is coming properly but "1 of 6" is not resolving.
I will check it, Please check on NOGTITLE
Thanks,
Majeti
@DR_Majeti wrote:
Hi Kriss,
"nogtitle" with combination title "page ^{thispage} of ^{lastpage}" has some reltation.
If you remove the "nogtitle" option in ODS PDF then graph is coming properly but "1 of 6" is not resolving.
I will check it, Please check on NOGTITLE
Thanks,
Majeti
@DR_Majeti The "1 of 6" not resolving is likely as SAS version issue as it resolves on my 9.4.4 okay when using GTITLE.
Hi Majeti,
Thank you. I removed nogtitle, but it's still not working. I am using SAS 9.4.
Hi:
Look at this Tech Support note: http://support.sas.com/kb/34/573.html. It has the workaround of using &totpage, as you show. This was an interaction between graphs and {lastpage} that was reported in SAS 9.2 and doesn't look like it is fixed yet.
Cynthia
Update (5/9/2018): there was a defect reported on this issue. It appears that the issue is fixed in 9.4 M5 release. So if you are experiencing this problem, then upgrading to 9.4M5 should fix the issue.
Thanks for confirming Cynthia, and for this information.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.