BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Florent
Quartz | Level 8

Dear ODS experts,

 

I am struggling with the customization of the table of contents that is automatically generated by SAS when combining multiple PROC REPORT statement.

 

The aim of my program is to generate a SAS Data Dictionary of all the datasets available in all the libnames which are available at the moment my program is executed. I am generating one HTML file per SAS dataset available in the libraries (using an "ODS HTML Body" statement inside a macro do loop). This part works as expected.

 

I have also coded my PROC REPORT" statement inside the macro do loop, in order to populate the BODY part of each individual HTML file with the related data. As expected, each execution of this "PROC REPORT" generates a level2 node in my Table Of Contents (displaying the full name of the related SAS dataset, for instance "WORK.INPUT_DATA" and "WORK.OUTPUT_DATA"). I managed to give the expected name to those level2 nodes of my TOC by using the < contents="&Lib..&DsName" > option in the PROC REPORT statement.

 

What is not appearing as expected is the repetead level1 entries for each ODS HTML file that is generated. I would like to have only one iteration of the same level1 node (corresponding to an individual libname which is available in my session) in the TOC. I define the value of the level1 nodes by using an ODS proclabel statement < ODS PROCLABEL "&Lib"; >

 

So taking into account the two datasets mentioned above (i.e. "WORK.INPUT_DATA" and "WORK.OUTPUT_DATA"). I would like to have a unique level1 node "WORK" under which my two level2 nodes "WORK.INPUT_DATA" and "WORK.OUTPUT_DATA" will be indented.

 

Here below, a small representation of what I would like to build as TOC for my data dictionary:

 

1) WORK
           ° WORK.INPUT_DATA
           ° WORK.OUTPUT_DATA


2) TEST
           ° TEST.MY_DATA
           ° TEST.MY_OLD_DATA
... etc

 

You can find a capture of my current TOC in attachment.

 

It's really important to me that SAS keeps on creating a specific HTML document by SAS dataset (i.e. I don't want all SAS datasets of a same library to be exported in the same HTML document. Each document being linked to the same TOC, which is displayed in a frame document (this part works with my current code). My problem is thus to "simply" group all datatesets referenced by the level2 entries of the TOC, below the level1 entry of the TOC to which they belong (knowing that the level1 entries of the TOC the are library names).

 

Thanks a lot in advance for your help!

 

Regards,

Florent


TOC.JPG
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Hi:
I believe that you could do this with ODS DOCUMENT and PROC DOCUMENT, as shown in this paper: https://support.sas.com/resources/papers/sgf09/318-2009.pdf look at the original TOC on page 2 and the "adjusted" TOC on page 11, Figure 21 -- in the paper, what is under each TOC is a different procedure's output, but it could be output objects from multiple runs of the same procedure.

cynthia

View solution in original post

6 REPLIES 6
Cynthia_sas
SAS Super FREQ
Hi:
I believe that you could do this with ODS DOCUMENT and PROC DOCUMENT, as shown in this paper: https://support.sas.com/resources/papers/sgf09/318-2009.pdf look at the original TOC on page 2 and the "adjusted" TOC on page 11, Figure 21 -- in the paper, what is under each TOC is a different procedure's output, but it could be output objects from multiple runs of the same procedure.

cynthia
Florent
Quartz | Level 8

Hi Cynthia,

 

Thanks a lot for the quick answer!

 

I am going to give it a try on tomorrow as soon as I arrive at the office. I thought that the PROC DOCUMENT was only to be used with ODS PDF/RTF.

 

I am busy reading the SAS book you wrote to about ODS, it's crystal clear so far. Very well explained, congratulations.

 

Florent

Cynthia_sas
SAS Super FREQ
Look at some of the REPLAY examples later in the paper. I used ODS HTML, RTF and PDF.
cynthia
Florent
Quartz | Level 8
It works like a charm, thanks for the lead!
Florent
Quartz | Level 8

Hello Cynthia,

 

Could you please review my code (in attachment) and let me know whether it would be possible to enhance the results as described below?

 

  • I don't understand why, after replaying the new (re-arranged) document store, I get duplicated nodes at level 2. Once with the expected name (defined while re-arranging the document store, by using the "setlabel" statement of PROC DOCUMENT), and once with the old label "Table 1" Smiley Frustrated
  • After replaying the new document store, I would like to have the same body files to be generated instead of having all the results of my proc reports into the same body file (name "AllDatasets.htm" since I did not manage to have it work the same way as before re-arranging the "work.tempDoc" document store).
  • I would like the "Path" displayed by the PROC REPORT to contain an embedded weblink. I thought that using the "escapechar" and  "protectspecialchars = off" would make the trick but obviously not...
  • The hyperlink that I apply on the "format" field in my PROC REPORT does not work whereas I can see the related HTML files have been created at the expected location.

I have spent a lot of time searching for solutions by myself (with the support of books and SUGI's) but could not manage to have it work as I want. Really frustrating... Smiley Mad So my last shot is by asking to the SAS community.

 

Thanks a lot in advance for your support.

 

Kind regards,

Florent

Cynthia_sas
SAS Super FREQ

Hi:

I forget the version where the extra "Table 1" node was created by PROC REPORT, maybe it was 9.2, but I believe you need to delete that node BEFORE you save your results in the document store. This Tech Support note has an example of the code you use:
http://support.sas.com/kb/31/278.html

When I use the technique described in the note and save the output to an ODS DOCUMENT store and then replay the output, I do not get a stray Table 1 node.

I am on other projects this week and not in a position to review such lengthy or complex code especially since it cannot be run without making significant changes and creating test files and formats. It also appears that every reference to a Desktop location has to be changed. Plus, diving into code like this without an idea of either the current results or the desired results makes it harder to connect code to output.

  

However, when I test building and using a URL and a FILE drilldown in a much simpler program, without the TOC, or a document store or macro coding, the links in the program below all work for me.

URLs_and_FILE_links_work_in_my_example.png

I'm sure that you started with a working SAS program that had working links before you "macro-ized" the program. So at what point in the process did the URL and the PATH break? If you started with a working SAS program and if all the links worked before you macro-ized the program, then you can probably backtrack to the point where the links broke.

  

When I run this program (below), the HTTP links and the FILE links all work for me. So there must be something happening to your links when you build them to cause them to break--perhaps there is a place where one of the variables you concatenate to make the path is missing for some row. You could probably debug this by undoing all the NOPRINTs in PROC REPORT to see what's going on.

   

Like I said at the beginning, I think the Tech Support note above will get rid of the Table 1 node for you. I hope this points you toward some resolution. Otherwise, for more in-depth help, you might need to work with Tech Support.

  

cynthia

 

proc sql;
create table DSinfo as
  select * from dictionary.tables
    where libname='SASHELP' and MEMNAME in ('CLASS' 'SHOES');
quit;
  
** make some files to drill down to;
 ods html file='c:\temp\class_contents.html';
   proc contents data=sashelp.class;
   run;
ods html close;
  
ods html file='c:\temp\shoes_contents.html';
  proc contents data=sashelp.shoes;
  run;
ods html close;
  
ods html path='c:\temp' (url=none)
         file='main.html';
  proc report data= DSinfo 
       contents= '' nowindows   split='*';
    column libname memname path drilldown crdate modate nobs obslen nvar;
    define Path / computed "Test URL with Google";
    define drilldown / computed 'Drill Down To';
    compute path / character length=100;
        hipath='http://www.google.com#q=';
        path=catt('<a href="',hipath,memname,'"> The search is: ',memname,'</a>');
    endcomp;
			  
    compute drilldown / character length=100;
        hipath2='file:///c:\temp\';
        drilldown=cat('<a href="',trim(hipath2), trim(memname),'_contents.html">', trim(memname),' contents</a>');
    endcomp;

    compute before _page_ / style=Header{just=l fontweight=bold};
	line 'Libname: SASHELP';
	line '<a href="http://support.sas.com/training">Go To Training</a>';
	line '<a href="file:///c:\temp\shoes_contents.html"> Look At Shoes</a>';
	line '<a href="file:///c:\temp\class_contents.html"> Look At Class</a>';
    endcomp;
  run;
ods html close;

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 2658 views
  • 0 likes
  • 2 in conversation