Desktop productivity for business analysts and programmers

table titles orphaned in ods printer

Reply
New Contributor
Posts: 4

table titles orphaned in ods printer

I run monthly programs that output series of print and tabular procedures (proc freq, proc means etc.). Each list or table can be a couple lines to hundreds of lines, varying from month to month. I want to remove all page breaks. The following code works except that table titles do not always go to next page when table is too large for remaining space. I tried ods pdf text= and other options, but can't solve this. Can someone help?

ods pdf file = "a:\ods\sample092610.pdf" startpage=no body style=styles.newpdf
title="Report for Sample Program";

data data1;
/* input statements */
run;

/* this subset may have a couple records or hundreds, no way to know where page
break should occur for next procedure */

proc print data=data1;
title2 "Sample Print Title";
where var1 = "Sample";
run;

proc freq data=data1;
title2 "This title is orphaned from table if table doesn't fit on same page";
tables var2;
run;
SAS Super FREQ
Posts: 8,720

Re: table titles orphaned in ods printer

Hi,
Are you sure that the syntax you show is the EXACT syntax that you are submitting?? When I run your code, exactly (except for STYLE=), this is the error message I get.
[pre]
329 ods pdf file = "c:\temp\sample092610.pdf" startpage=no body
330 title="Report for Sample Program";
-----
73
202
ERROR 73-322: Expecting an =.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
[/pre]

So then, when I take out TITLE=, this is the error message I get:
[pre]
375 ods pdf file = "c:\temp\sample092610.pdf" startpage=no body;
-
73
76
ERROR 73-322: Expecting an =.
ERROR 76-322: Syntax error, statement will be ignored.
[/pre]

TITLE= is a suboption that is available to the ODS HTML destination. In addition BODY= is an alias for FILE=. Since you have FILE= in your code, BODY= is not needed.

Suggest you post the actual error-free code that was submitted.

In the meantime, one thing you could do (although it violates your "no page break" desired output) is to put an explicit startpage=now before the PROC FREQ:
[pre]
ods pdf startpage=now;
proc freq ...;
[/pre]

OR

Another possibility is to investigate the use of ODS TEXT= or, alternately, ODS PDF TEXT= (if you are running SAS 9.1.3), then the syntax would be
[pre]
ODS TEXT="Text string to insert"; /* SAS 9.2 */

ODS PDF TEXT="Text string to insert"; /* SAS 9.1.3 */
proc freq ...;
[/pre]

This would allow you to insert a text string to take the place of the title.

When you use STARTPAGE=NO, the only title that gets placed on the output page is the title that "belongs" to the procedure in effect at the "top" of the page. Once you have removed the normal page-breaking behavior (which also removes the normal title behavior if you have 2 procedures' output on the same page), there is no place for ODS PDF to put the TITLE statement -- since TITLE statement for PDF always goes at the top of the page.

cynthia
New Contributor
Posts: 4

Re: table titles orphaned in ods printer

Sorry, I left some of the RTF syntax in there. Copied below is what I should have sent. I guess I am looking for an ODS function comparable to 'linesleft' in a file statement, but it sounds like that is not possible?

Thanks a lot for the help.

ods pdf file = "a:\ods\sample092610.pdf" startpage=no style=styles.newpdf
title="Report for Sample Program";

data data1;
/* input statements */
run;

/* this subset may have a couple records or hundreds, no way to know where page
break should occur for next procedure */

ods pdf text = "Sample Print Title";

proc print data=data1;
where var1 = "Sample";
run;

ods pdf text = "This title is orphaned from table if table doesn't fit on same page";

proc freq data=data1;
tables var2;
run;
SAS Super FREQ
Posts: 8,720

Re: table titles orphaned in ods printer

Hi:
There is no ODS function equivalent to LINESLEFT (which is a DATA step and FILE PRINT option -- that only works in the LISTING destination). And, anyway, when you are using SAS procedures, you cannot really control the writing of output on a "line-by-line" basis -- think of the procedure as building an output report and then, while that output report is being "transmitted" to the destination, you cannot "interrupt" the transmission to check for something like LINESLEFT -- it's just not a concept that applies in this scenario.

Also, ODS is not responsible for RENDERING the output report -- if the destination is PDF, then a PDF viewer (like Acrobat Reader) is responsible for rendering the output report; if the destination is RTF, then a word processor (like Word) is responsible for rendering the output report; if the destination is HTML-based, then a browser (like IE, Safari or Firefox) is responsible for rendering the output report. Only the LISTING destination (or Output Window) is responsible for rendering tabular output reports in SAS. All other destinations use 3rd party applications for viewing or rendering. And, if you are using SAS Enterprise Guide and the SASReport XML destination, EG has a way to make the XML view-able inside EG.

In the DATA step, you control what's written with every PUT statement; but with the PROCEDURE step, the transmission of the output report is inside a "black box" -- which is why options like STARTPAGE and TEXT= are specified on ODS statements -- because they impact what happens between procedures. STARTPAGE removes the normal page break instructions at the beginning of a procedure and TEXT= inserts a text string either before or after a procedure's output. For example, if your PROC FREQ were to break -across- pages, the TEXT= string would only be placed BEFORE the procedure output -- one time; it would NOT repeat at the top of any subsequent pages of the PROC FREQ output.

A few other notes. I notice you are using a custom style template, STYLES.NEWPDF in your output creation. If you want to make the TEXT= strings look more like a title, you can add or use similar syntax inside your PROC TEMPLATE code:
[pre]
style usertext from usertext /
just=c
background=white
font_size=12pt
font_weight=bold
foreground=black;
end;
[/pre]

The USERTEXT style element is responsible for formatting the TEXT= strings.

Also, do remember that TITLE= is NOT a valid ODS PDF option.

cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 124 views
  • 0 likes
  • 2 in conversation