Help using Base SAS procedures

ODS PDF Proc Report Compute Block

Reply
Occasional Contributor
Posts: 6

ODS PDF Proc Report Compute Block

[ Edited ]

Hi,

 

I'm using multiple proc report statements to generate number/percentage frequency tables to a PDF. Each table starts on a new page. Each table has header notes and footer notes of varying lengths. I'm using compute before/after blocks with line statements to generate this text. For few tables, the header notes are extensive, causing the table to break into multiple pages. The problem is, the header notes are repetitively printed on each page the table is broken down into, as they are printed by line statements in a 'compute before _page_' block. Is there a way to apply a conditional statement to execute the compute before block only if it is the first page of the proc report table? Thanks.

 

===========================

PROC REPORT DATA = X MISSING;

COLUMN A A=B DUMROW N PCTN;

 

COMPUTE A;
COUNT+1;
IF (MOD(COUNT,2)) THEN DO;
CALL DEFINE (_ROW_, 'STYLE', 'STYLE=[BACKGROUND=WHITE]');
END;
ENDCOMP;

 

TITLE J=LEFT "Table Title";

 

COMPUTE BEFORE _PAGE_/STYLE=[JUST=L FONTSIZE=2];
LINE "Header note 1";
LINE " ";
LINE "Header note 2";
LINE " ";
ENDCOMP;

 

DEFINE A /"Value" GROUP ORDER=INTERNAL FORMAT=NOPRVAL. ;
DEFINE B /"Label" GROUP ID FORMAT=B. NOPRINT ;
DEFINE DUMROW /COMPUTED "Label";
DEFINE N /"Unweighted Frequency" FORMAT=COMMA12. ;
DEFINE PCTN /"%" FORMAT=PERCENT7.1 ;

 

COMPUTE DUMROW /CHAR LENGTH = 50;
IF _BREAK_="_RBREAK_" THEN DO DUMROW = 'Total'; END;
ELSE DUMROW=PUT(B, B.);
IF DUMROW = 'Total' THEN CALL DEFINE (_ROW_, 'STYLE', "STYLE=[BACKGROUND=LIGHT GRAY FONTSTYLE=ITALIC FONTSIZE=2]");
ENDCOMP;

 

RBREAK AFTER / SUMMARIZE;

 

COMPUTE AFTER/STYLE=[JUST=L FONTSIZE=2];
LINE " ";
LINE "Footer note 1";
LINE "Footer note 2";
LINE " ";
LINE "Footer note 3";
ENDCOMP;
RUN;

=========================

Contributor
Posts: 52

Re: ODS PDF Proc Report Compute Block

[ Edited ]

Hi

I've noted some possible options below:

  • Use a text box for the header notes.  This would appear once and it has a lot of control over style to get the appearance you need.

ods region width=10cm height=1cm x=1.25cm y=2.1cm;
ods text = "^{style[font_face='calibri' fontsize=1.5
just=left fontweight=bold] HEADER NOTE 1}";

 

  • Use multiple TITLE statements.   Apply style elements to title3 and title4 to get the appearance you need.  Reset at the end of the proc with title;

TITLE J=LEFT "Table Title";
title2 "";
title3 "Header note 1";
title4 "Header note 2";

 

  • Try to style a big label which spans across the column headers?  I think this would reprint if went over one page though.

COLUMN ("header note 1 header note 2" A A=B DUMROW N PCTN);

 

 

Occasional Contributor
Posts: 6

Re: ODS PDF Proc Report Compute Block

Posted in reply to RB1Kenobi

Thanks for the response RB1Kenobi.

 

I tried using option 1 suggested by you but the ODS PDF text gets printed at the end of the previous table page (as there are multiple proc report tables printed and the previous proc report table isn't long enough). So I guess, the follow up question would be, how to start processing on a new page between two proc report statements which are finally printed to one PDF? 

=================================

ODS PDF FILE = "file1.pdf";

 

proc report data = x;

column ... ... ... ...;

title 'table 1 title';

compute before _page_/ style=[just=l];

line 'table 1 header 1';

endcompute;

define ... ... ... ;

define ... ... ... ;

run;



/*  HOW TO END PAGE HERE?  */

 

ods pdf text = 'table 2 header 1';

proc report data = x;

column ... ... ... ...;

title 'table 2 title';

define ... ... ... ;

define ... ... ... ;

run;

 

ODS PDF CLOSE;

=====================================

 

And I don't think I can use option 2: multiple title statements, as in some tables, the header notes go well beyond 20-25 lines. Thank you.

Contributor
Posts: 52

Re: ODS PDF Proc Report Compute Block

Hi

Define the start of the page with: 
ods pdf startpage=now;

 

define the end of the page with :
ods layout end;

 
This is a good ODS resource:
http://support.sas.com/documentation/cdl/en/odsug/65308/HTML/default/viewer.htm#titlepage.htm

Occasional Contributor
Posts: 6

Re: ODS PDF Proc Report Compute Block

[ Edited ]
Posted in reply to RB1Kenobi

Thanks again! I was able to suppress the repetition of the header notes by using ods pdf text and provide a page break by "ods pdf startpage = now". Now I get Title, header notes, half the table on page 1 and half the table on page 2.

 

But now, I'm left with a SAS generated message at the top of the 'second' page reading "Continuing contents of page nn, which would not fit on a single physical page" AND the title is not printed on the second page where the table spills on to. What are the options to suppress this sas generated message but print the table title instead, in this scenario? 

 

I looked around and a method to suppress this message when ods pdf text spills over to second page is, providing a blank proc report statement. But in my case, the message needs to be suppressed when the proc report table spills over to the second page while using ods pdf text. 

 

Thank you.

Contributor
Posts: 52

Re: ODS PDF Proc Report Compute Block

Sorry, I don't know the answer to that.
Would your table fit onto one page if you reduced font & cell padding etc?
Occasional Contributor
Posts: 6

Re: ODS PDF Proc Report Compute Block

Posted in reply to RB1Kenobi

Thank you RB1Kenobi.

 

The tables are pretty big and they do need to be on two full pages to be readable.

Occasional Contributor
Posts: 6

Re: ODS PDF Proc Report Compute Block

Can someone help me with the issue?

 

I need to suppress the SAS generated text box message "Continuing contents of page nn, which would not fit on a single physical page" when a proc contents table overflows to more than one page. Being able to repeat the table title instead on the second page would be an added bonus. Thank you.

Ask a Question
Discussion stats
  • 7 replies
  • 497 views
  • 2 likes
  • 2 in conversation