I would like to generate an automatic table of contents in Word using the wordstyle and prepage statements. When I try to do this, the table of contents looks fine, but the text specified in the prepage statement is within a little one-celled table. Is there a way to change this and make the text of the prepage statement look more like a title? I would also like to change the font.
Even if I make the gridlines around the prepage text invisible, the text is still part of the table, and I want the actual text to not be part of the table, but separate like a title. Is this possible?
In SAS 8, you could just use a title statement to make a table of contents, but this seems not to work in SAS 9, so I wanted to try it with the prepage statement. I am not getting the results I want.
I guess that as powerful as prepage and wordstyle are, I find that I can do a lot with simpler techniques.
Ever since ODS PROCLABEL and CONTENTS=YES work together, I find that many of the kinds of thing I was tempted to do with WORDSTYLE, I can do with ODS PROCLABEL and the string I specify there shows up automatically in the Table of Contents created with CONTENTS=YES. (see code sample below)
I have already tried using the ods proclabel and contents=yes, but these provide a way more detailed TOC than I need. All I want is to have the variable name in the TOC, I don't need the detailed list (sometimes there are three entries for just one table!)
I have thoroughly read through the paper that you reference already and found the second method (with the wordstyle option) to be the most convenient. However, I was just frustrated that I could not change the prepage text from not being part of the table.
However, if I do decide to live with the fact that the text is in a table, how can I change the font? One poster above mentioned being able to change it to bold and italic, but how can I change the font face? I have created my own style with proc template, but can't figure out which style I would have to change in the template to change the prepage text. If I can also do it in the ods prepage statement, then that would be okay as well.
I believe that to change the font face, you'd have to define a Word Style or change a Word Style (in normal.dot) so that Heading1 was a particular font face. This is a good question for Tech Support.
I'd probably take a different approach instead of prepage. It sounds to me like you want to change the hierarchy in the table of contents -- to flatten the levels that you see. So this might be a good job for ODS DOCUMENT.
ODS DOCUMENT allows you to create a DOCUMENT from your procedure's output objects -- it's like a "frozen" image of your output objects after the procedure is finished, but before the output objects get sent to the final ODS destination.
That means you can rearrange the output objects or make new folders or flatten the hierarchy of the folder structure. I generally do this by creating one copy of the "original" structured document and then making a new document store with the structure I want. That way, I have a backup of the original output objects and I can always prove that I did nothing to change the output from the procedure, I just rearranged it.
Then, once I've done the rearranging and/or relabeling I want, I can REPLAY the new ODS DOCUMENT to whatever destination I want. There is a point and click window that lets you do the rearranging and renaming very easily. Since it's a LOT of steps, I took the easy way out and built a program using the batch syntax of PROC DOCUMENT to do the same thing as I would do in the point and click window, but it has the added advantage of being something that I can post and you can run (in SAS 9.1.3).
Note that if you use my code, then the document store goes away when the SAS session is over because I have written everything to the WORK library.
The ODS DOCUMENT way to "flatten" the table of contents:
options nodate nonumber center orientation=portrait;
** make a subset of data;
proc sort data=sashelp.shoes out=shoes;
where region in ('Asia', 'Pacific');
** make a new document store;
** and show the "original" RTF contents;
ods document name=work.shoedoc(write);
ods rtf file='c:\temp\origrtf_file.rtf' contents=yes;
proc means data=shoes min mean max;
** Get information on the new ODS DOCUMENT;
** specifically, the names of the output objects for later copying;
proc document name=work.shoedoc;
list / levels=all;
** now build a new document store with the folder structure;
** and object names and labels we want;
** but I had to know the "official" object names which I cut and pasted from;
** the LISTING in the step above;
** And, there is a stray page break that I want to take out before the PROC MEANS;
** Summary object for Asia;
** I could also insert page breaks, but that is a different example;
** I also want to add some titles and some "before" notes that will;
** be different for Asia and Pacific.;
proc document name=work.newshoedoc2(write);
make ASIA, PACIFIC;
copy \work.shoedoc\Freq#1\ByGroup1#1\Table1#1\OneWayFreqs#1 to ^;
copy \work.shoedoc\Means#1\ByGroup1#1\Summary#1 to ^;
copy \work.shoedoc\Freq#1\ByGroup2#1\Table1#1\OneWayFreqs#1 to ^;
copy \work.shoedoc\Means#1\ByGroup2#1\Summary#1 to ^;
obtitle1 \ASIA#1\OneWayFreqs#1 'New Title for Asia';
obbnote1 \ASIA#1\OneWayFreqs#1 'Not many Boots sold here.';
obtitle1 \PACIFIC#1\OneWayFreqs#1 'New Title for Pacific';
obbnote1 \PACIFIC#1\OneWayFreqs#1 'More Boots sold here.';
ods listing close;
options nodate nonumber orientation=portrait center;
** now replay the new document store with the contents= option;
ods rtf file='c:\temp\newtoc.rtf' contents=yes;
proc document name=work.newshoedoc2;
ods _all_ close;
This is the only document I've found that lets me manipulate an html contents file in my code.
However, I'm coming up a little short. On the setlabels, I have everything defined and working for tables. But I am also trying to reference a proc gchart procedure. When I run the code like I have for the tables, the contents page keeps the default name (HBar chart of Item) rather than the name I am assigning it with the setlabel.
Also, is it possible to remove the enumeration from the contents page?
The reason the original questions (in the notes) were about HTML, is that you -do- see numbered contents items in the HTML TOC. But, when I get a TOC with RTF, I don't get numbers on the left in the TOC, (unless I put them in myself) so I'm not sure what enumeration you want to remove?? The page numbers that appear on the right?
I see what you mean about the GCHART, you're right, it doesn't seem to use the setlabel string in the TOC. It seems to use my DES= string:
vbar age / discrete
So one workaround might be to use DES= for the string you want to see in the TOC. The description can be up to 256 characters.
You might want to work with Tech Support if you have more ODS DOCUMENT questions -- as the code can get quite lengthy and they have the most experience with ODS DOCUMENT.