BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sasjourney
Calcite | Level 5

Hi,

Can someone help me how to get page no using the proc template.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi,

  How you put a line on a report depends on whether you want the RTF or the PDF destination. Since you're using JOURNAL style, and since JOURNAL works in either destination, I am going to guess you want RTF. There was a previous forum posting from a LONG time ago on this topic:

https://communities.sas.com/message/2531#2531

  And it shows a simple way using a FOOTNOTE statement. The output may not be exactly what you want, but it's a start. I'd recommend opening a track with Tech Support. Especially if you want a PDF output instead of RTF. Many folks who need a line at the bottom of each page resort to making a "fake page break variable" (which has also been written about in the forum) and they use features of PROC REPORT to write a line on every page. Depending on your destination and what you want, I think the Tech Support is your best bet.

cynthia

View solution in original post

7 REPLIES 7
Cynthia_sas
SAS Super FREQ

Hi:

  Did you search on support.sas.com? There's a Tech Support note that illustrates the template way to impact the page number when it is at the top of the page. Otherwise, there is a second method using ODS ESCAPECHAR, as shown in the program below that is a modification of the code in the Tech Support note.

cynthia

ods path work.template(update)

      sasuser.templat(update)

      sashelp.tmplmst(read);

  /*

   modified from Tech Support note:

     http://support.sas.com/kb/24/460.html

  */

        

  proc template;

    define style mystyle;

    parent=styles.printer;

    Style PageNo from PageNo  /

          color=cyan

          font_face='Courier New'

          font_weight=bold

          font_size=14pt;

    end;

  run;

  

option nodate;

ods escapechar='^';

ods pdf file="c:\temp\testpgno.pdf" style=mystyle;

ods rtf file="c:\temp\testpgno.rtf" style = mystyle;

  footnote j=r bold font='Courier New' h=14pt color=red

           '^{thispage} of ^{lastpage}';

      

  title "One" ;

  proc print data=sashelp.class(obs=3); run;

  

  title "Two" ;

  proc print data=sashelp.class(obs=3); run;

ods _all_ close ;

title;

footnote;

sasjourney
Calcite | Level 5

Hi Cynthia,

Thanks for the reply. I did try this way and the actual footnotes are getting overwritten with the page number (page x of y).

Thanks

Cynthia_sas
SAS Super FREQ

Hi:

  You do NOT have to use my footnote statement. I just included it as an alternate example of a way to put page numbers on a document. For example, if your footnote is FOOTNOTE1, and you actually WANT the page X of Y page numbering, then make the X of Y footnote FOOTNOTE3, so it is the last thing written to the page.

  Otherwise, I do not understand what you mean when you say that the "actual footnotes are getting overwritten with the page number" -- are you just using FOOTNOTE and not FOOTNOTE1, FOOTNOTE2, FOOTNOTE3, etc? Since you didn't show any code, it is hard to understand what you mean. In the code below, I've removed the template from the picture and have just used the TITLE and FOOTNOTE statements. Since I am putting X of Y in the footnote, I make it the LAST (highest number) footnote. I do not observe any "overwriting" of the page number.

  If you run my code and you observe that your footnotes are not being written correctly for either the RTF or PDF destination (the only destinations that support X of Y), then you should probably open a track with Tech Support on this issue.

cynthia

option nodate nonumber;

ods escapechar='^';

 

ods pdf file="c:\temp\altpgno.pdf" ;
ods rtf file="c:\temp\altpgno.rtf" ;

  footnote1 bold j=l 'Left' j=c "Actual Footnote" j=r 'Right';
  footnote2 bold 'Footnote2';
  footnote3 bold italic 'Footnote3';
  footnote4 bold italic c=cyan h=14pt 'Footnote4';
  footnote5 bold italic c=purple h=8pt 'Footnote5';

  footnote6 j=r bold font='Courier New' h=14pt color=red
           '^{thispage} of ^{lastpage}';
   
  title "One" ;
  proc print data=sashelp.class(obs=3); run;
   
  title "Two" ;
  proc print data=sashelp.class(obs=3); run;
   
ods _all_ close ;
title;
footnote;

sasjourney
Calcite | Level 5

Hi Cynthia,

Thanks for the quick reply. The problem I had here is, I'm trying to automate it using the template procedure to appear at the bottom right of each page of a report because I can't use the "footnote" statement since the number of footnotes may differ for different tables.

Thanks

Cynthia_sas
SAS Super FREQ

Hi:

  The challenge in automating page numbering as you describe (and you may want to verify this with Tech Support) is that I believe the style template only controls style for the default page number location in the upper right corner of your output report. So the ONLY way, as far as I know to place a page number in the lower right corner or bottom right corner is to use the ODS ESCAPECHAR syntax in a FOOTNOTE statement.

cynthia

sasjourney
Calcite | Level 5

Hi Cynthia,

Thank you very much for the information. Yes, you are right the style controls only the default location of page number for rtf output. Also, can you please help me out how to get a line at the bottom of each page before the footnotes. For example if I use the Journal template and if the report is of multiple pages I get a line after the end of the report, So is there any way to get a line at the bottom of each page. I was able to get a line using page break but the problem here is, I have two lines if the report is small(one soon after the end of report as per journal style and one at the bottom of page from page break).

Thanks

Ram

Cynthia_sas
SAS Super FREQ

Hi,

  How you put a line on a report depends on whether you want the RTF or the PDF destination. Since you're using JOURNAL style, and since JOURNAL works in either destination, I am going to guess you want RTF. There was a previous forum posting from a LONG time ago on this topic:

https://communities.sas.com/message/2531#2531

  And it shows a simple way using a FOOTNOTE statement. The output may not be exactly what you want, but it's a start. I'd recommend opening a track with Tech Support. Especially if you want a PDF output instead of RTF. Many folks who need a line at the bottom of each page resort to making a "fake page break variable" (which has also been written about in the forum) and they use features of PROC REPORT to write a line on every page. Depending on your destination and what you want, I think the Tech Support is your best bet.

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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
  • 7 replies
  • 2540 views
  • 3 likes
  • 2 in conversation