{bygrouplastpage} is not a valid function I am looking for equivalent.
The proc report option BYPAGENO=1 resets the page numbers at the beginning of each by group. I also want the {lastpage} of the by group as in the RTF {sectionpages} function.
Hi, I believe this Tech Support note describes what you're seeing and how to get what you want:
39423 - The BYPAGENO= option on the PROC REPORT statement might produce incorrect page numbers
cynthia
I've seen that note but I have SAS 9.3 so that is not the issue the numbering is correct. I want to number "Page n of p" within each by group 1 of 3, 1 of 5 etc. right now I can only use {lastpage} and I get 1 of 197, 2 of 197, 3 of 197 and for the next group 1 of 197, 2 of 197 etc. I would like a "{function}" that gives last page of by group.
NULL,
why not make it on your own based on this sample code ? You has so strong data step skill.
options nobyline orientation=landscape; ods escapechar='^'; proc sort data=sashelp.shoes out=sorted; by region; run; data _null_; set sorted; by region; if first.region then do; count+1;n=0;m=0; call symput('region'||trim(left(count)),trim(left(region))); end; n+1; if mod(n,24)=1 then m+1;/*a page has 24 data row -- You need change it according to your SAS system*/ if last.region then call symput('last'||trim(left(count)),trim(left(m))); call symput('count',trim(left(count))); run; %put _user_ ; %macro loopit; %do i=1 %to &count; options pageno=1; proc report data=sashelp.shoes nowd; by region; where region="&®ion&i"; column subsidiary product stores sales inventory returns; define subsidiary/order; define product/display; define stores/display; define sales/display; define inventory/display; define returns/display; title f=Arial h=14pt c=black 'Product Report for the #byval1 Region'; footnote j=center f=Arial h=8pt c=black "Page ^{thispage} of &&last&i "; run; %end; %mend; ods pdf file='c:\temp\aaa.pdf'; %loopit ods pdf close;
Xia Keshan
Hi: If you feel it should be available, why not add that as a SAS ballot item? Otherwise, the suggestion in the full code snippet should work for you, too. The first number might be correct, but the solution in the code snippet will fix the last number too, as Ksharp demos -- you can loop through your by groups with a macro program and then the page numbers will do what you want.
cynthia
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.
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.