The SAS Output Delivery System and reporting techniques

Proc document and nogtitle

Reply
Contributor ckx
Contributor
Posts: 54

Proc document and nogtitle

I'm experimenting with PROC DOCUMENT to merge output results to a single document with a table of contents but I've run into some problems. The biggest problem relates to tites in SAS/Graph output.

I create my output using ODS RTF using the NOGTITLE NOGFOOTNOTE options and do the same when creating the merged document with PROC DOCUMENT. But in the merged document, the title is printed both inside and outside the graph. If I use PROC GREPLAY  then I see the title is included in the Graph. Is there any way to stop this?

Problem 2: If I use ODS RTF to create the merged document then page numbering is wrong, "page 1" is numbered twice, then page numbering commences normally. Is there any solution to this?

Problem 3: Using TAGSETS.RTF, page numbering is correct, after selecting all in Word and pressing F9 to update all fields. But now, the second page is blank! Any help on this?

These are the sample programs I used (with SAS 9.4 on a Windows 2008 server and using Enterprise Guide):

T1.SAS

ods document name=odsdoc.t1(write);

ods rtf file = "&_outrtf\&_progname..rtf" toc_data;

title1 h=8pt "Test program &_progname..SAS" j=r "Page ^{thispage} of ^{lastpage}";;

title2 h=8pt "OR sales data";

footnote h=8pt j=l "&_progname" j=r "&sysdate9.";

ods proclabel="OR sales data";

proc report data =sashelp.orsales( obs = 5 ) nowindows;

    columns year quarter product_line;

run;

ods _all_ close;

----------------------------------------------------------------------------------------------------------

T2,sas

ods document name=odsdoc.t2(write);

ods rtf file = "&_outrtf\&_progname..rtf" toc_data;

title1 h=8pt "Test program &_progname..SAS" j=r "Page ^{thispage} of ^{lastpage}";;

title2 h=8pt "Shoes data";

footnote h=8pt j=l "&_progname" j=r "&sysdate9.";

ods proclabel="Shoes data";

proc report data =sashelp.shoes( obs = 5 ) nowindows;

    columns region product stores;

run;

ods _all_ close;

----------------------------------------------------------------------------------------------------------

T3,sas

ods document name=odsdoc.t3(write);

ods rtf file = "&_outrtf\&_progname..rtf" toc_data;

title1 h=8pt "Test program &_progname..SAS" j=r "Page ^{thispage} of ^{lastpage}";;

title2 h=8pt "Class data";

footnote h=8pt j=l "&_progname" j=r "&sysdate9.";

ods proclabel="Class data";

proc report data =sashelp.class( obs = 5 ) nowindows

    style(column header)=[font_size=8pt];

run;

ods _all_ close;

----------------------------------------------------------------------------------------------------------

T4,sas

ods document name=odsdoc.t4(write);

ods rtf file = "&_outrtf\&_progname..rtf" toc_data nogtitle nogfootnote;

goptions ftext='Arial' ftitle='Arial/bold';

title1 h=8pt "Test program &_progname..SAS" j=r "Page ^{thispage} of ^{lastpage}";;

title2 h=8pt 'Scatter Plot of Height and Weight';

footnote h=8pt j=l "&_progname" j=r "&sysdate9.";

ods proclabel='Scatter Plot of Height and Weight';

proc gplot data=sashelp.class gout=odsdoc.gseg;

    plot height* weight = sex;

    run;

quit;

ods _all_ close;

----------------------------------------------------------------------------------------------------------

Replay,sas

ods output documents=documents;

proc document;

    doc library=odsdoc;

run;

quit;

ods output close;

proc sql;

    select name into :docs separated by ' ' from documents order by name;

quit;

%put &docs;

%let _publish=&_progdir\..\65 Publish Results;

goptions vsize=10cm hsize=15cm ftext='Arial' ftitle='Arial/bold';

options orientation=portrait gstyle;

ods tagsets.rtf file="&_publish\&_progname..rtf" nogtitle nogfootnote

    options(toc_data='yes' contents='yes' TOC_LEVEL='1');

%macro replay;

    %local i currdoc;

    %let i=1;

    %let currdoc=%scan(&docs,&i,%str( ));

    %do %while (%length(&currdoc) gt 0);

        proc document name=&currdoc;

            replay;

        run;

        quit;

        %let i=%eval(&i+1);

        %let currdoc=%scan(&docs,&i,%str( ));

    %end;

%mend;

%replay;

ods _all_ close;

----------------------------------------------------------------------------------------------------------

Any help is greatly appreciated!

_gp

Super User
Super User
Posts: 7,401

Re: Proc document and nogtitle

Hi,

Afraid my response is not going to be too helpful.  I have looked at this type of thing several times over the last few years and output generation with contents page/linked/pagenumbered etc. is very tricky and in most scenarios not possible directly from SAS.  For instance, one of my posts on this matter:

It also depends on the requirements, should page number consecutive, should it be within subsections, etc.  Generally I have seen that there is a separate team which builds documents outside of my area, thus setting things up as need there.  In theory you could send your output to RTF, then use Word VBA scripting to create all the additional elements then print to PDF, or you could do a fair bit in Adobe JS scripting. 

So my suggestion would be to create your output RTF files, or PDF, with their respective page numbering, then do all the fancy work outside SAS. 

One other suggestion is to look into DocBook, which is XML.  As its text you can write it directly, following the layout/DSD then use any DocBook to PDF composer to render it.  One day I will get a chance to look at it myself.

DocBook 5: The Definitive Guide - O'Reilly Media

SAS Super FREQ
Posts: 8,743

Re: Proc document and nogtitle

Hi:

  My recommendations are related, but slight changes to what you recommend. When you are creating the ODS DOCUMENT, I generally recommend blanking out all the titles and all the footnotes and not using any at all. That way, you can use the OBPAGE commands to put your own titles on the pages at replay time. I also recommend OPTIONS NODATE NONUMBER; should be in effect when you create the ODS DOCUMENT store, that way you can combine output objects at replay time and let the page numbering sync in the NEW document. That has been the cleanest for me.

  Word is tricky with Page X of Y page numbering. In some versions of Word, you have to whack Word with a repaginate command to get it to renumber the whole document, otherwise, you get funky numbers like Page 10 of 1 or Page 1 of 1 on all the pages until you repaginate. This might actually be a question better answered by Tech Support. because I do not see what the ODS DOCUMENT is buying. And if the desired result is to end up with 1 RTF file, why not just make it in one pass? Each of the 4 steps is overwriting file="&_outrtf\&_progname..rtf" -- the same named RTF file. I don't see a point to that.

    

cynthia

Contributor ckx
Contributor
Posts: 54

Re: Proc document and nogtitle

Thanks Cynthia, RW9, for the replies. @RW9, I actually do use a VBA macro to merge RTF files. It works well, but slowly. I noticed there were numerous improvements in PROC DOCUMENT in SAS 9.4 so I was hoping that would provide a quicker solution. Installing the macro on other accounts is also a pain and there's a high probability that a new version of Word will require modifications.

@Cynthia, if I have to blank out the tiles and footnotes when generating the ODS DOCUMENT output then I wonder if its worth the hassle.Is there perhaps a way to extract the titles and footnotes from the ods document files? For SAS/Graph output in any case, it looks like I'm stuck with creating them without titles/footnotes.

I'm afraid my examples weren't really clear enough. I have 4 files T1.SAS to T4.SAS, that generate output. &_progname and &_progdir are derived by an autoexec.sas, &_progname contains the filename of each file so the output is overwritten. Replay.sas is written to merge an arbitrary number of ODS DOCUMENT files. In this simple example it would be just as easy to included the 4 files but for my work, I need to merge many more results.

Thanks for your help,

John Hendrickx

SAS Super FREQ
Posts: 8,743

Re: Proc document and nogtitle

Hi:

  I don't know whether there is a way to extract the titles and footnotes from the ODS DOCUMENT file. The challenge is that I think (but I'm not 100% sure) that the titles and footnotes are attached to the page break as the document was originally created to have page breaks. So this may or may not be "extractable". That is a question for Tech Support. If you look at the example in my paper, (from a while ago) http://support.sas.com/resources/papers/sgf09/318-2009.pdf starting on page 19, you will see that I use OBBNOTE and you could use OBTITLE to give a different title to each output object. But this is possibly not what you had in mind. I just found when I was writing the paper that if I had titles and footnotes in effect when I created the document, more often than not, I ended up deleting them and using my own OBTITLE and OBBNOTE commands to insert titles and notes where I wanted.

  That was my practice, It may not be the thing for you. It really depends...

cynthia

Contributor ckx
Contributor
Posts: 54

Re: Proc document and nogtitle

Hi Cyntia,

I really don't want to go the obtitle/obnote route. And I've made some progress in finding solutions to my problems!

To avoid getting titles and footnotes in your SAS/Graph output, you can generate the SAS/Graph output using GOPTIONS NODISPLAY. That will create an entry in the graphics catalog specified by the GOUT option, without titles and footnotes. Then, set GOPTIONS DISPLAY and use  PROC GREPLAY to replay the graph.

goptions ftext='Arial' ftitle='Arial/bold' nodisplay;

title1 h=8pt "Test program &_progname..SAS" j=r "Page ^{thispage} of ^{lastpage}";;

title2 h=8pt 'Scatter Plot of Height and Weight';

footnote h=8pt j=l "&_progname" j=r "&sysdate9.";

ods proclabel='Scatter Plot of Height and Weight';

proc gplot data=sashelp.class gout=odsdoc.gseg;

    plot height* weight = sex;

    run;

quit;

goptions display;

proc greplay igout=odsdoc.gseg;

    replay _last_;

run;

quit;

You must use PROC GREPLAY or the graph won't be included by PROC DOCUMENT.


As for the empty page after the first table/document, I found that could be avoided by using the SECT='OFF' option in tagsets.rtf. But that will also mean you can't switch between landscape and portrait, which I do want to be able to do.


If you show hidden characters in the PROC DOCUMENT output using tagsets.rtf by pressing Shift+8 in Word, you can see that after the first table, there is a new page and a new section starting at a new page. If you remove that section, select all and update fields by pressing F9, the problem is fixed.


An even better solution is to use TAGSETS.RTF_SAMPLE (which I learned about in your 2012 post in https://communities.sas.com/thread/39133). No problems here with redundant page skips. An added attraction (for me) is that titles and footnotes are in the Word header and footer. There's no documentation though on TAGSETS.RTF_SAMPLE.


New Contributor
Posts: 3

Re: Proc document and nogtitle

Hi,

 

i'm sorry to reactivate this topic after a long time.

 

I would like to know if you have a solution about wrong numbering of page in RTF ?

 

Thank's a lot

 

M.H

SAS Super FREQ
Posts: 8,743

Re: Proc document and nogtitle

Hi,
You might want to open a track with Tech Support. I believe that you might need to repaginate the document after you open it in Word, to get the page numbers to behave correctly.

cynthia
Ask a Question
Discussion stats
  • 7 replies
  • 958 views
  • 1 like
  • 4 in conversation