BookmarkSubscribeRSS Feed
cjridley
Calcite | Level 5

Hi there,

 

I'm trying to run SAS graph into a sas item store before replaying into a single PDF using PROC DOCUMENT and the issue I have is that I only want to present the top level bookmark in the PDF.

 

I see various methods and solutions for achieving this for PROC REPORT (using the contents ="") however I cannot find a similar SAS/GRAPH solution for when the graphs span more than one page. 

 

Using the description option only controls the bookmark name, and when setting description = "" this only creates a blank bookmark where as I do not want this bookmark creating at all.

 

Below is some sample code to show the issue I face.

 

Any help would be very much appreciated!

 

ods document name=temp(write);   

proc sort data=sashelp.class out=class; by sex; run;

ods noproctitle;
ods proclabel="";
proc sgplot data=class description="";
 by sex;
 scatter x=height y=weight;
run;

ods document close;

/* Create data set from all levels */
 ods output properties=temp;                                                                                                            
proc document name=temp;                                                                                                                
   list / levels=all;                                                                                                                      
run;                                                                                                                                    
quit;                                                                                                                                   
      
/* Create a unique macro variable for each object */
data _null_;                                                                                                                            
   set temp end=last;                                                                                                                    
   if type in("Table","Report","Graph") then do;
      count+1; 
      call symput('path'||trim(left(count)),path); 
   end; 
   if last then call symput('total',count); 
run;  
                                                                                                                   
 /* Loop through each macro variable and copy the output */
 /* object to a new folder and then replay it.           */
%macro test;  

   ods pdf file="temp.pdf"; 
   proc document name=temp; 
      make \ newfolder; 
      setlabel \ newfolder "I only want one level of bookmark for this SGPLOT";
      %do i=1 %to &total; 
         copy &&path&i to \ newfolder#1;
      %end;                                                                                                                                   
      replay \newfolder;                                                                                                                      
   run;                                                                                                                                    
   quit; 

   ods pdf close; 
%mend;                                                                                                                                  
                                                                                                                                          
%test;
2 REPLIES 2
MCoopmans
SAS Employee

The trick of not having the procedures generate the bookmark, but instead creating one yourself should work with SGraph procedures just as well. 
I modified your code a bit, does this come close to what you are looking for ?

 

ods document name=temp(write);   

proc sort data=sashelp.class out=class; by sex; run;

ods noproctitle;
ods proclabel="";
proc sgplot data=class description="";
 by sex;
 scatter x=height y=weight;
run;

ods document close;

/* Create data set from all levels */
 ods output properties=temp;                                                                                                            
proc document name=temp;                                                                                                                
   list / levels=all;                                                                                                                      
run;                                                                                                                                    
quit;                                                                                                                                   
      
/* Create a unique macro variable for each object */
data _null_;                                                                                                                            
   set temp end=last;                                                                                                                    
   if type in("Table","Report","Graph") then do;
      count+1; 
      call symput('path'||trim(left(count)),path); 
   end; 
   if last then call symput('total',count); 
run;  
                                                                                                                   
 /* Loop through each macro variable and copy the output */
 /* object to a new folder and then replay it.           */

%macro test;  

ods pdf file="c:\temp\want.pdf" startpage=no;
ODS PROCLABEL 'First bookmark';


data _null_;
  declare odsout ODS();
  ODS.note(data: " ",  style_attr: 'font_size=1pt');
run;

ods pdf nobookmarkgen;

   proc document name=temp; 
      make \ newfolder; 
      setlabel \ newfolder "I only want one level of bookmark for this SGPLOT";
      %do i=1 %to &total; 
         copy &&path&i to \ newfolder#1;
      %end;                                                                                                                                   
      replay \newfolder;                                                                                                                      
   run;                                                                                                                                    
   quit; 

%mend;                                                                                                                                  
                                                                                                                   
%test;

ods pdf close; 
cjridley
Calcite | Level 5

Hi Mathias.. thanks for the response

 

Whilst the below statement has the desired outcome of only creating the output with 1 bookmark, this also affects the actual plot where a 3 page document is created with the first 2 pages blank and then the third shows only a truncated part of the plot. 

data _null_;
  declare odsout ODS();
  ODS.note(data: " ",  style_attr: 'font_size=1pt');
run;

I'm not so familiar with controlling ODS documents from a datastep, so any pointers to address this would be really appreciated.

 

Thanks

 

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1218 views
  • 0 likes
  • 2 in conversation