The SAS Output Delivery System and reporting techniques

Creating new page w/ the ID statement in PROC REPORT?

Reply
New Contributor
Posts: 4

Creating new page w/ the ID statement in PROC REPORT?

I'm running a PROC REPORT that generates under ODS RTF. The table that is created can viewed as having 2 parts, one part, on the left handside that list items, such as Age, Weight, Height and others and their associated statistics, and the next part on the right handside that list all the groups in a study.

For one of the studies there are more groups/columns than there is room on a page to display them all. I used the ID option on the last "item" variable so that all the are repeated.

I do get a new table w/ the item names and statistic labels and all the groups that couldn't fit on the first table. However what I would like is for a new page with the titles to be created, instead of having the table w/ the remaining groups displayed below the first table.

Is that possible?

TIA!
Super Contributor
Posts: 394

Re: Creating new page w/ the ID statement in PROC REPORT?

Hi Stéph,

Try using the PAGE option on the DEFINE statement for the first group you want to appear on the 2nd page. The PAGE option forces that column and all the columns to its right to appear in a new table on a new page. The ID columns will appear in the new table, too.
New Contributor
Posts: 4

Re: Creating new page w/ the ID statement in PROC REPORT?

Thanks for the suggestion Tim. The problem I have is that the DEFINE statement for the "group" columns is done using a "%DO" loop:

%do g=%eval(&grp_min.) %to %eval(&grp_max.);
define c&g. / style=[cellwidth=%sysevalf(&grp_wdt.)in
just=center];
%end;

I guess I could estimate how many groups would fit on a page and using a "%IF" add the "PAGE" statement when needed. But there the problem I'm going to run into is that the width of the "group" columns as you can tell from the code above is a macro parameter, plus font face and size can also both vary depending on the style being used.
New Contributor
Posts: 4

Re: Creating new page w/ the ID statement in PROC REPORT?

Come to think about it the width of the column to display the "item" variable is itself a macro parameter. The font face and size won't affect the width available on a page for the columns, only the left and right margins.

I haven't searched yet, but if there's a way to retrieve the values of the left and right margins defined in the template style being used, then I guess I could estimate how many columns can be displayed on a page and once I get that "magic" number, use it to put the "PAGE" option in the "DEFINE" statement...
Super Contributor
Posts: 394

Re: Creating new page w/ the ID statement in PROC REPORT?

I understand where you're going with this but I don't think it's (currently) do-able. There's no way to programatically determine style attributes. PROC REPORT doesn't know anything about panels or RTF, it just knows about columns. RTF doesn't know how many panels will fit on a page because it doesn't know the page's length.

However, for what it's worth, the new "measured RTF" support in SAS 9.2 has an option that lets you specify the maximum number of panels on a page (because measured RTF does know about page lengths) so you could do exactly what you're asking for. I realize that doesn't help you much today. Sorry.
New Contributor
Posts: 4

Re: Creating new page w/ the ID statement in PROC REPORT?

I realise the pagination when using ODS RTF cannot be controlled within PROC REPORT as well as it is when generating a TXT file. So my goal is to address it either before the PROC REPORT or forcing it in the PROC REPORT.

So far I've already taken care of the pagination by deriving a variable that stores, for each observation, which page it's expected to appear on. Using the following statement in the PROC REPORT: "BREAK AFTER &pgno_var. / PAGE;", I can control when page breaks are inserted, so that has taken care of the "vertical" pagination.

So now I only need to address the horizontal one. I do realise that my derived page numbers are going to be off when I've got more columns than what can fit on a page, but if I can control the layout, I think I'd be willing to give up the accuracy of the page numbering.

Now I've been searching on PROC TEMPLATE and it seems the only way to retrieve the values for the style is to send the whole template to a file:
proc template;
source pharma/file='pharma.txt';
run;
and then read the file and search for the "leftmargin" & "rightmargin"...

Is there a way to send these directly to a dataset w/o having to generate a file?

If I know the width of page, which is determined by the dimension of the paper used (letter, A4...) minus the margins, then I'll know what width is available for the display of the columns. I know the "item" column width and the "group" column width, since these are macro parameters. I know the total number of groups to be reported as well, it's also a macro parameter. So I think I should be able to estimate how many groups can fit on a page. Then in my "%DO" loop for the "group" colums, I can add a "%IF" to insert the "PAGE" option when a mulitple of the "magic" number is dealt with.
Ask a Question
Discussion stats
  • 5 replies
  • 618 views
  • 0 likes
  • 2 in conversation