BookmarkSubscribeRSS Feed
mmkr
Quartz | Level 8

Hi,

 

Can some one help me to dsiplay report like below .

 

I am looking for Regular Page Number , BY variable page number on same line (left,,right)

 

Page number : 1       Byvariable:State:MN : Page No :1

Page number : 2       Byvariable:State:MN : Page No :2

Page number : 3       Byvariable:State:MN : Page No : 3

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

 

Page number : 4       Byvariable:State:OH : Page No :1

Page number : 5       Byvariable:State:OH : Page No :2

Page number : 6       Byvariable:State:OH : Page No : 3

 

Thanks

6 REPLIES 6
ballardw
Super User

Do you already have a "by variable page number" somewhere or are you asking how to generate one? Not a trivial exercise by any means if "how to generate".

Are you using a Proc Report option like a _page_ variable?

 

mmkr
Quartz | Level 8

Title1 j=l "Total Report Page No:~{thispage}"

    j=r "By Variable Page No:~{thispage}" 

proc report data=outputtable;by state;

run;

 

 

How do i write whene evr state changes then i need page no should reset ?

ballardw
Super User

@mmkr wrote:

Title1 j=l "Total Report Page No:~{thispage}"

    j=r "By Variable Page No:~{thispage}" 

proc report data=outputtable;by state;

run;

 

 

How do i write whene evr state changes then i need page no should reset ?


You can get a value for STATE in the title using #byval. Since there is nothing in the proc report BY statement with a page number then not going to happen.

You may be able to insert a raw code for a particular ODS destination to access something like a section page number but depends on ods destination and those specific codes and will have nothing to do with Proc Report code.

Cynthia_sas
SAS Super FREQ

Hi:

  You can make it so that every by group starts a new page, as shown below:

Cynthia_sas_0-1718995673439.png

  However, there's nothing within SAS that would allow you to have multiple page numbers such as you show (where OH by group is on pages 4,5 and 6 but you want a second page number to show a second set of page numbers as 1,2 and 3 on the right side of the page.

  My guess is that to do what you show, you'd need to run each by group separately probably in some kind of macro program and you might need to generate your own "secondary" page number for every by group, which can be quite fiddly, since the number of observations per page can change based on font size and other style settings.

Cynthia

mmkr
Quartz | Level 8

understood but i need to reset page number when ever by variable starts new one.

 

 

 

 

Cynthia_sas
SAS Super FREQ

Hi:

  There is only a single page number in SAS and as you can see, it DOES reset at the beginning of each by group because every by group starts a new page. But there's no "internal" page number for each by group. This means you can't have the standard page number for the entire document and then have a separate page number for each by group, automatically. That's not how SAS works by default. If you want a different "BY Group" page number for each by group, then you need to set up some kind of programming logic and variable that you calculate ahead of time that you can use as a secondary by group page number and then use that in the title or come up with a macro solution to pre-calculate the page number within each by group and store that value so it can be used in the title. This means you have to know ahead of time how many rows are in each by group and how many rows can reasonably fit on a page when you include titles, footnotes and summary lines (if any).

Cynthia

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 6 replies
  • 679 views
  • 0 likes
  • 3 in conversation