Hello, everybody!
I'm trying to do a pdf with bookmarks, and my question is:
Can I control the second level of the bookmarks ?
For example: I have two proc reports.
Proc report data=sashelp.class contents= “ Weight < 95” nowd;
Columns name age weight height;
Define name /display;
Define age/display;
Define weight/display;
Define height/ display;
Where weight <95;
Run;
Proc report data=sashelp.class contents= “ Weight >= 95” nowd;
Columns name age weight height;
Define name /display;
Define age/display;
Define weight/display;
Define height/ display;
Where weight >=95;
Run;
If you run these reports probaly the bookmark will be like this:
I'd like to know if a Can do something like the picture below:
Thanks in advanced !!!
Actually I can paste plain text.
ods listing close;
ods document name=TOCtest(write);
proc report data=SASHELP.CLASS contents= " Weight < 95" nowd;
where WEIGHT <95;
columns NAME AGE WEIGHT HEIGHT;
define NAME /display;
define AGE/display;
define WEIGHT/display;
define HEIGHT/ display;
run;
ods noptitle ;
ods proclabel " ";
proc report data=SASHELP.CLASS contents= " Weight >= 95" nowd;
where WEIGHT >=95;
columns NAME AGE WEIGHT HEIGHT;
define NAME /display;
define AGE/display;
define WEIGHT/display;
define HEIGHT/ display;
run;
ods document close;
proc document name=TOCtest;
ods listing;
list / levels=all; run;
ods listing close;
ods pdf file="before.pdf" ;
replay; run;
ods pdf close;
setlabel \Report#1 "Class";
*setlabel \Report#1\Report#1\Report#1 "< 95";
*setlabel \Report#2\Report#1\Report#1 ">= 95";
move \Report#1\Report#1\Report#1 to \Report#1;
move \Report#2\Report#1\Report#1 to \Report#1;
delete \Report#1\Report#1;
delete \Report#2;
/* I'd rather make a new tree, but it misbehaves
make \Class;
* move (where=(_TYPE_ = 'Table') to \Class#1;
move \Report#1\Report#1\Report#1 to \Class#1;
move \Report#2\Report#1\Report#1 to \Class#1;
delete \Report#1;
delete \Report#2; */
ods pdf file="after.pdf";
replay \Report#1; run;
ods pdf close;
dir \;
ods listing;
list / levels=all; run;
ods listing close;
quit;
Here is a solution
data a;
set sashelp.class; xc=1;run;
ods pdf file="d:\temp\twolevels.pdf" bookmarkgen=yes ;
ods proclabel "first knot global";
Proc report data=a contents= " Weight < 95" nowd;
Columns xc name age weight height;
define xc /group noprint;
break before xc / contents="" page;
Define name /display;
Define age/display;
Define weight/display;
Define height/ display;
Where weight <95;
Run;
ods noptitle ;
ods proclabel " ";
Proc report data=a contents=" Weight >= 95" nowd;
Columns xc name age weight height;
define xc /group noprint;
break before xc / contents="" page;
Define name /display;
Define age/display;
Define weight/display;
Define height/ display;
Where weight >=95;
Run;
ods pdf close;
the trick is to create a non visible xc that could help us to eliminate the third level in the report
HTH
Andre
contents="" and not contents=" "
Hi Andre,
my problem is the second level if you see the second picture.
Look:
Your code:
What I need ....
tk's in advanced !!
Manually
as the third level you want is dependent of the empty second
or
go into this solution i never have test
http://support.sas.com/kb/16/215.html0
Andre
support.sas.com/resources/papers/proceedings11/252-2011.pdf
Hi:
In addition to Andre's comments, if you save your output objects in an ODS DOCUMENT store, you can use PROC DOCUMENT statements to restructure, rearrange and replay your saved output objects to a different structure, including restructing the TOC or bookmarks.
I wrote a paper about this a few years ago
http://support.sas.com/resources/papers/sgf09/318-2009.pdf
That has some examples of the restructuring that you can do with ODS DOCUMENT.
cynthia
A lot of things that look like they should work don't, but then proc document is not my cup of tea (yet).
Here is the closest I could get.
I don't know why the stuff in green doesn't do what it is supposed to.
Crappy IE8 won't let me past text,sorry, so here is a screenshot.
Actually I can paste plain text.
ods listing close;
ods document name=TOCtest(write);
proc report data=SASHELP.CLASS contents= " Weight < 95" nowd;
where WEIGHT <95;
columns NAME AGE WEIGHT HEIGHT;
define NAME /display;
define AGE/display;
define WEIGHT/display;
define HEIGHT/ display;
run;
ods noptitle ;
ods proclabel " ";
proc report data=SASHELP.CLASS contents= " Weight >= 95" nowd;
where WEIGHT >=95;
columns NAME AGE WEIGHT HEIGHT;
define NAME /display;
define AGE/display;
define WEIGHT/display;
define HEIGHT/ display;
run;
ods document close;
proc document name=TOCtest;
ods listing;
list / levels=all; run;
ods listing close;
ods pdf file="before.pdf" ;
replay; run;
ods pdf close;
setlabel \Report#1 "Class";
*setlabel \Report#1\Report#1\Report#1 "< 95";
*setlabel \Report#2\Report#1\Report#1 ">= 95";
move \Report#1\Report#1\Report#1 to \Report#1;
move \Report#2\Report#1\Report#1 to \Report#1;
delete \Report#1\Report#1;
delete \Report#2;
/* I'd rather make a new tree, but it misbehaves
make \Class;
* move (where=(_TYPE_ = 'Table') to \Class#1;
move \Report#1\Report#1\Report#1 to \Class#1;
move \Report#2\Report#1\Report#1 to \Class#1;
delete \Report#1;
delete \Report#2; */
ods pdf file="after.pdf";
replay \Report#1; run;
ods pdf close;
dir \;
ods listing;
list / levels=all; run;
ods listing close;
quit;
You gave a "helpful reply" star to yourself Abud instead of Andre. It is odd that this is even possible.
Did you manage to get correct level 2 labels instead of "Table 1" ?
Hi Chris !
Thanks for letting me know about the error. Sorry Andre.
The code it's working almost perfectly (the labels are correct "<95" and ">95").
Now I'm reading the document (about proc document) to understand...
If you have more tips about this subject, please send by e-mail, it's very important for me......
Tk's in advanced
How did you get the labels to work properly Abud?
Abud
I have read more about document and
from my solution the program is becaming now
ods listing close;
ods noptitle;
data a;
set sashelp.class; xc=1;run;
ods document name=testTOC(write);
ods pdf file="d:\temp\twolevels.pdf" bookmarkgen=yes ;
ods proclabel "Class";
Proc report data=a contents= " Weight < 95" nowd;
Columns xc name age weight height;
define xc /order noprint;
break before xc / contents="" page;
Define name /display;
Define age/display;
Define weight/display;
Define height/ display;
Where weight <95;
Run;
ods proclabel " ";
Proc report data=a contents=" Weight >= 95" nowd;
Columns xc name age weight height;
define xc /order noprint;
break before xc / contents="" page;
Define name /display;
Define age/display;
Define weight/display;
Define height/ display;
Where weight >=95;
Run;
ods pdf close;
ods document close;
ods ptitle;
ods listing;
proc document name=testTOC;
list/ levels=all; run;quit;
ods listing close;
proc document name=newtestTOC(write);
make CLASS;
dir ^^;
dir CLASS;
dir;
copy \work.testTOC\Report#1\Report#1 to ^;
copy \work.testTOC\Report#2\Report#1 to ^;
run;
list/ levels=all; run;
quit;
proc document name=work.Newtesttoc;
ods pdf file="d:\temp\twolevelscorrect.pdf";
replay;
run;
ods pdf close;
quit;
with this results
I found it more easier to reconstruct a new document in place of moving and loosing node+labels!
I recall that colored code was copied to word and then recopied from word to this screen.
Andre
Here is my final try and success
i agree about the fact that it is quite difficult with that mixed of non natural code
ods html close;
ods noptitle;
data a;
set sashelp.class; xc=1;run;
ods document name=testAW(write);
ods proclabel "Class";
Proc report data=a contents= "Weight < 95" nowd;
Columns xc name age weight height;
define xc /order noprint;
break before xc / contents="" page;
Define name /display;
Define age/display;
Define weight/display;
Define height/ display;
Where weight <95;
Run;
ods proclabel " ";
Proc report data=a contents="Weight >= 95" nowd;
Columns xc name age weight height;
define xc /order noprint;
break before xc / contents="" page;
Define name /display;
Define age/display;
Define weight/display;
Define height/ display;
Where weight >=95;
Run;
ods pdf close;
ods document close;
ods ptitle;
ods listing;
proc document name=testAW;
list/ levels=all; run;
quit;
*ok ok;
proc document name=testAW2(write);
make CLASS;
dir ^^;
dir CLASS;
make Tab1;
setlabel \Class#1\Tab1#1 "weight < 95";
copy \work.testAW\Report#1\Report#1\Report#1 to \Class#1\Tab1#1;
make Tab2;
setlabel \class#1\Tab2#1 "weight >95";
copy \work.testAW\Report#2\Report#1\Report#1 to \Class#1\Tab2#1;
run;
list/ levels=all; run;
quit;
proc document name=work.testAW2;
ods pdf file="d:\temp\twolevels.pdf";
replay;
run;
ods pdf close;
quit;
Friday i did not see that the third level was producing an item in the toc
now it is without.
Andre
Hi everbody!
Chris/Andre sorry, I was sick and because of that, I couldn't answer, but now, I think the last post is correct.
In my opinion the best think is create a proc report and to change the layout with ptoc document.
What about you ?
Yes but break before is necessary
otherwise some more items and thus levels are reappearing !!
Andre
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.