BookmarkSubscribeRSS Feed
Kandi
Calcite | Level 5
How do I change pdf bookmark labels in an ODS pdf statement to equal the title for each Proc Report when I have multiple Proc Report statements within the same ods statement?
5 REPLIES 5
Cynthia_sas
Diamond | Level 26
Hi:
Two ways to touch bookmarks are:
1) ODS PROCLABEL statement BEFORE each PROC REPORT or
2) CONTENTS= option on each proc report statement.

cynthia

[pre]
ods pdf file='lovelucy.pdf';

ods proclabel 'Lucy';
Proc report data=sashelp.class nowd
contents='Love Lucy';
run;

ods proclabel 'Ethel';
Proc report data=sashelp.class nowd
contents='Ethel Rocks';
run;
ods pdf close;
[/pre]
Lex_SAS
SAS Employee
When I run this code in 9.1.3 I get the following bookmarks:

Lucy
+---Love Lucy
Ethel
+---Ethel Rocks

Great!
But in 9.2 I get bonus bookmarks:

Lucy
+---Love Lucy
+---Table1
Ethel
+---Ethel Rocks
+---Table1

Is there any option that will get rid of the Table1 bookmarks?
Or do I have to start using ODS Document to fix this compatibility issue ?

Thanks,
Lex Jansen
Cynthia_sas
Diamond | Level 26
Hi:
Ah, you're right. It's a feature that the extra level got introduced, as described here:
http://support.sas.com/kb/31/278.html

To cope with it, there's a new capability -- contents= on the BREAK before xxx statement -- that will allow you to either name it or disappear it. You have to make a "fake variable" to break on and use the PAGE option on the break statement, but it will do what you want. (Note that you will change the PDF bookmarks, but NOT the Results Windows nodes.)

cynthia
[pre]
data class;
set sashelp.class;
fakevar = 1;
run;

ods listing close;
ods pdf file='lovelucy.pdf';

ods proclabel 'Lucy';
Proc report data=class nowd
contents='Love Lucy';
column fakevar name age height sex;
define fakevar / order noprint;
break before fakevar / contents='Ricky' page;
run;

ods proclabel 'Ethel';
Proc report data=class nowd
contents='Ethel Rocks';
column fakevar name age height sex;
define fakevar / order noprint;
break before fakevar / contents='' page;
run;
run;
ods pdf close;
[/pre]
Lex_SAS
SAS Employee
Thanks, Cynthia!

It works, but it does get a little hard to maintain code that has to be compatible with older versions.

Since the hyperlinks in my PROC REPORTS use absolute column references (like _c3_), I now have to update them (in this example to _c4_), since I added a fake variable.

Any ideas to prevent this, except adding a lot of code like this: %IF &sysvar=9.2 %THEN ...

Regards,
Lex Jansen Message was edited by: LexJ
Cynthia_sas
Diamond | Level 26
Hi, Lex:
I feel your pain. It's not the best solution if you have to maintain code for multiple versions -- especially with ACROSS variables in the mix. My tendency would be to modularize the code for each version -- create fakevar & shift the absolute columns for 9.2 and use the "old way" for 9.1.3 -- but maintain them as 2 separate programs.

Sorry, I don't have a better idea.

cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2940 views
  • 0 likes
  • 3 in conversation