How do I keep observations together (on consecutive pages) in Proc Report?

Reply
New Contributor
Posts: 2

How do I keep observations together (on consecutive pages) in Proc Report?

I have a report with 21 columns so the ID option is imperative in the 3rd Display statement. Therefore, the columns 1-3 are shown on every page. There are many records in the dataset and I'm using SAS v9.4.

 

It turns out that columns 1-9 appear on the first page that shows the first 35 records. Page 2 shows columns 1-9 for records 36-70; page 3 shows columns 1-9 for records 71-105, etcetera until all records have been displayed. Then, after columns 1-9 have been displayed for all records, the next page shows columns 1-3 and 10-15 for the first 35 records, followed by columns 1-3 and 10-15 for the next 35 records, etcetera.

 

What I really want is for page 1 to show columns 1-9 for the first 35 records, then page 2 should show columns 1-3 and 10-15 for these same records, then page 3 shows columns 1-3 and 16-21 for the same 35 records. After ALL columns for the first 35 records are displayed, then I want the next 35 records to be shown on consecutive pages until the columns have been exhausted (that is, columns 1-9 on a page; columns 1-3 with 10-15 on the next page; and columns 1-3 with 16-21 on the next page).

 

I guess another way of saying this is I want Proc Report to keep observations together across consecutive pages.

 

I searched the internet and discussion boards without luck. Any ideas?

Super Contributor
Posts: 407

Re: How do I keep observations together (on consecutive pages) in Proc Report?

Sorry, can't help to solve the issue. But i am curious: what is the purpose of a report that i have to print and arrange the sheets on my desk to read it?

Super User
Super User
Posts: 8,609

Re: How do I keep observations together (on consecutive pages) in Proc Report?

Nope, there is no magic do my report button, you have to design it.  Me, if I need a complicated report output I manipulate the data beforehand.  This is one place where splitting the data out does make sense, split it out so you get the data you want to see on each page, assign sort order variables so that you can group/order properly (using order=data), plus you can control line splitting/page splitting easier.  

Super User
Posts: 12,148

Re: How do I keep observations together (on consecutive pages) in Proc Report?

Summarize the data, sort in the desired order and use multiple proc print statements with the VAR statement changing.

 

Or possibly Proc tabulate with multiple tables statements with the first 3 row variables the same and an ods destination setting to start each table on a new page.

 

Or send output to something in landscape orientation with largish paper and a style that uses a small font. 21 columns sounds quite doable, depending on the column widths, to fit on legal paper in landscape orientation.

 

It might help to show your proc report code to get better results.

 

 

 

Trusted Advisor
Posts: 1,139

Re: How do I keep observations together (on consecutive pages) in Proc Report?

You have 35 observations per page.  So consider something like

 

data need;

  set have;

  pagnum=ceil(_n_/35);

run;

 

Can you then run your proc report with a BY PAGNUM statement?   If the BY-line can't be eliminated, I guess you might have to go with 34 or 33 obs per pagnum.

New Contributor
Posts: 2

Re: How do I keep observations together (on consecutive pages) in Proc Report?

I wish there was a SAS option to do this, but this answer is brilliant!

Thank you.

Ask a Question
Discussion stats
  • 5 replies
  • 93 views
  • 1 like
  • 5 in conversation