Hi,
I have a trivial question, considering the following dataset (MY_DATASET):
/*
Variable1 | Variable2 | Variable3 | Variable4 | Variable5 | Page | PageNumbering |
----------------------------------------------------------------------------------
xxxx1 | AAAAA | YY | LLL | W | 1 | Page 1 of 8 |
xxxx2 | AA | YYY | LLLLLL | WWWWWWWW | 1 | Page 1 of 8 |
xxxx3 | AAA | | L | WWW | 1 | Page 1 of 8 |
xxxx4 | AAAAA | YY | LLL | W | 2 | Page 2 of 8 |
xxxx5 | AA | YYY | LLLLLL | WWWWWWWW | 2 | Page 2 of 8 |
xxxx6 | AAA | | L | WWW | 2 | Page 2 of 8 |
...
*/
Consider the following PROC REPORT code:
proc report data=my_dataset headline nowd split="@" missing spacing=1;
column variable1 variable2 variable3 variable4 variable5;
by page;
%* ID Variable(s);
define variable1 / order order=internal id;
%* Page 1;
define variable2 / display;
define variable3 / display;
%* Page 2;
define variable4 / display;
define variable5 / display;
compute before _page_;
line @1 pagenumbering $200.;
encomp;
run;
Note: the code will produce an ODS RTF output. I have left this code off for simplicity.
As you can see, the code above will produce a "wide" PROC REPORT. What I mean by this, the output will produce two pages for every value of the PAGE variable:
Page 1 of x
Page=1
PageNumbering=Page 1 of 8
Variable1 Variable2 Variable3
Page 2 of x
Page=1
PageNumbering=Page 1 of 8
Variable1 Variable4 Variable5
The Issue:
The current code will print a line of text above the table on each page via the COMPUTE block. However, as the output is wide the page numbering is repeating, and I know why, but I was curious is there a nice solution, that I do not know about, which will give me the correct page numbering per page.
Page 1 of 16
Variable1 Variable2 Variable3
Page 2 of 16
Variable1 Variable4 Variable5
Notice the Pagenumbering variable has changed 8 to 16 (due to there are technically 2 pages per page as the output is wide) and that the page number is counting correctly. Note, I have created two new PageNumbering variables, so I have these at my disposal too:
/* Variable1 | Variable2 | Variable3 | Variable4 | Variable5 | Page | PageNumbering | PageNumbering1 | PageNumbering2 | ------------------------------------------------------------------------------------------------------------------------- xxxx1 | AAAAA | YY | LLL | W | 1 | Page 1 of 8 | Page 1 of 16 | Page 2 of 16 | xxxx2 | AA | YYY | LLLLLL | WWWWWWWW | 1 | Page 1 of 8 | Page 1 of 16 | Page 2 of 16 | xxxx3 | AAA | | L | WWW | 1 | Page 1 of 8 | Page 1 of 16 | Page 2 of 16 | xxxx4 | AAAAA | YY | LLL | W | 2 | Page 2 of 8 | Page 3 of 16 | Page 4 of 16 | xxxx5 | AA | YYY | LLLLLL | WWWWWWWW | 2 | Page 2 of 8 | Page 3 of 16 | Page 4 of 16 | xxxx6 | AAA | | L | WWW | 2 | Page 2 of 8 | Page 3 of 16 | Page 4 of 16 |...
*/
So Variable2 and Variable3 would use PageNumbering1 and Variable4 and Variable5 would use PageNumbering2.
Things I have already tried (some work):
Any thoughts welcome.
Have you had a look at this post?
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: