BookmarkSubscribeRSS Feed
S_Proskurnin
Calcite | Level 5

I need to count how many observations fit on page in proc report. How to compute variable pagenum (e.g.) which consists page number?

Logic of this procedure (in pseudocode) is following:

L - number of rows per page

pagenum = 1

counter = 0

for observation in dataset:              #go through all observations in dataset

     counter += HowManyRows(observation)     #HowManyRows function returns number of rows which observation deposite on page

     if counter <= L*pagenum then:

          pagenum                              #write value pagenum into pagenum variable in datastep

     else:

          pagenum = pagenum + 1     #write value pagenum into pagenum variable in datastep

How to write similar logic in SAS?

At the end I'll obtain datastep with pagenum variable and I can write line statments before every page. Last question: does this line shift page content by 1 row and the last page row transfers to the next page?

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You question is a very complex one, and there are several papers out there.  You have to take into consideration font size, page orientation, width/height, style, line wrapping etc. And then it might not work.  If you just want page numbers then for RTF/PDF you can use:

ods escapechar= "^";

footnote j=r "Page ^{thispage} of ^{lastpage}";

That way pages are automatically generated for you.

Or the way I tend to do things, generate the output once, look at it and decide that maybe I want ten observations per page:

data want;

     set have;

     pgno=floor(_n_/10)+1;

run;

And use pgno as my break on / page in the proc report.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1197 views
  • 3 likes
  • 2 in conversation