hi,
I would like to a RTF file with the table of contents, listing table titles, at page 1 and tables at the following pages. The table of contents inserts wrongly interted into the table body when the toc_data was specified, as can be seen in the following screenshot:
The wrongly displayed table of contents disappeared when the NOTOC_DATA option was specified instead of the TOC_DATA, as shown in this screenshot:
My questions:
My script files and data are attached:
Thanks in advance!
Chang
Hi:
When I use this code in SAS 9.4, Windows,
Here's my code:
ods rtf file='c:\temp\maketoc.rtf' toc_data contents=yes;
proc print data=sashelp.class;
title 'SASHELP.CLASS';
run;
proc freq data=sashelp.class;
tables age sex;
run;
proc print data=sashelp.classfit;
title 'SASHELP.CLASSFIT';
run;
proc freq data=sashelp.classfit;
tables age sex;
run;
ods rtf close;
title;
And here are results. First, if I click on the "Show/Hide" symbol on the ribbon, I can see the section break at the end of the first page. SAS only puts the field codes into the RTF file, you must manually cause Word (or your word processor of choice) to build the TOC from the field codes. After I click Show/Hide, this is what I see:
Initially, when you look at the file after the Update Fields code, you will probably see the TOC and the field codes because the Show/Hide button is still active. But if you turn off the button, then the field codes are hidden again.
If you look closely at the first cell in the table, you can see that the whole field code is something like:
If you run my code and you DO get the same results that I show here, then there is something in your code that is causing the issue and you might want to open a track with Tech Support so they can look at your code and using your version of SAS and your operating system, see whether they can replicate the problem. If you run my code and you do NOT get the same results that I show here, then, that is also something that needs to be worked on with Tech Support. The Table of Contents in RTF has worked this way since SAS 9.2, so if my code does NOT work for you the same way that I illustrate in my screen shots, then something odd is happening.
cynthia
Hi:
When I use this code in SAS 9.4, Windows,
Here's my code:
ods rtf file='c:\temp\maketoc.rtf' toc_data contents=yes;
proc print data=sashelp.class;
title 'SASHELP.CLASS';
run;
proc freq data=sashelp.class;
tables age sex;
run;
proc print data=sashelp.classfit;
title 'SASHELP.CLASSFIT';
run;
proc freq data=sashelp.classfit;
tables age sex;
run;
ods rtf close;
title;
And here are results. First, if I click on the "Show/Hide" symbol on the ribbon, I can see the section break at the end of the first page. SAS only puts the field codes into the RTF file, you must manually cause Word (or your word processor of choice) to build the TOC from the field codes. After I click Show/Hide, this is what I see:
Initially, when you look at the file after the Update Fields code, you will probably see the TOC and the field codes because the Show/Hide button is still active. But if you turn off the button, then the field codes are hidden again.
If you look closely at the first cell in the table, you can see that the whole field code is something like:
If you run my code and you DO get the same results that I show here, then there is something in your code that is causing the issue and you might want to open a track with Tech Support so they can look at your code and using your version of SAS and your operating system, see whether they can replicate the problem. If you run my code and you do NOT get the same results that I show here, then, that is also something that needs to be worked on with Tech Support. The Table of Contents in RTF has worked this way since SAS 9.2, so if my code does NOT work for you the same way that I illustrate in my screen shots, then something odd is happening.
cynthia
I thikn you misunderstand what RTF is. RTF is a text markup language - quite an old one and not being developed any more. What you get out from your procedures is a text file which contains a whole set of control codes, and your text. This file is then opened in a renderer - from your example I assume your using Word. This renderer parses the text file and attempts to create an output representation based on the codes in the RTF. Generally speaking this works reasonably well, however if your doing things like contents pages and such like your going to have difficulties all round - Word's TOC function didn't even exist when RTF was made.
Can I ask wh you are building this in RTF? Almost all Study outputs I have seen are created in this way:
- Create an RTF output from SAS for each individual output
- Build a PDF for a compete section be that Tables, Listings, or Figures
- Document builder teams then incorperate those into the main CSR's or other documents
hi RW9,
I am using a script file from someone else. Whatever can export TOC and tables to a WORD document would be good. For this purpose, which ODS do you recommend?
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.