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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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