The SAS Output Delivery System and reporting techniques

macro in proc report

Frequent Contributor
Posts: 115

macro in proc report

%macro increaseSlideNo();
  %let slideNo = %sysfunc(putn(%eval(&slideNo + 1),z03.));
%mend increaseSlideNo;

To fulfil for one my requirement, I've to use below title and macro statements in each page break in proc report.

title  "#6A&slideNo.#SUMMARY REPORT"; 


would it be possible to use above two statements in page break in proc report

Posts: 9,031

Re: macro in proc report

Posted in reply to sunilreddy


  A SAS TITLE statement can only get issued BETWEEN procedure steps. That is your only opportunity to change the SAS TITLE. Without seeing the code for how you are generating the page break in PROC REPORT (using BY, using PAGE on BREAK??), it is hard to make a constructive comment. If you were using BY group processing, it is possible to use the special BY variables to get the title to change for a BY group.

  PROC REPORT does have the COMPUTE block, you could try COMPUTE BEFORE _PAGE_ -- but the text is within the boundary of the table, not at the top of the physical page. You did not say what your destination of interest was. You did not show any code other than your TITLE statement.

  Also, you did not show what is "inside" the %increaseSlideNo macro program -- for example, if there were only macro statement inside the macro program it might work. However, if there were an entire DATA step program or a PROC SQL step or any other procedure step inside the macro program, you cannot have the macro program generate any statements that would force a step boundary in PROC REPORT.

  For example, compare the placement of a BY variable in the title compared to the placement of the AGE value (coming from the COMPUTE BEFORE _PAGE_) in the attached screenshot.


proc sort data=sashelp.class out=class;

by age sex name;

where age in (13, 14, 15);



options nobyline nodate nonumber;

ods listing close;


ods html file='c:\temp\class.html';

ods rtf file='c:\temp\class.rtf';

ods pdf file='c:\temp\class.pdf';


proc report data=class nowd;

  title 'From BY Processing: Age is #Byval1';

  by age;

  column age sex name height weight;

  define age / group noprint;

  define sex / order;

  define name / order;

  define height / display;

  define weight / display;

  break after age / page;

  compute before _page_ /

          style={just=c font_weight=bold};

    disp_line = "From Compute Block Age is:"||trim(put(age,2.0))||" Summary Report";

    line disp_line $50.;




ods _all_ close;


options byline;

Senior User
Posts: 1

Re: macro in proc report

Posted in reply to Cynthia_sas



I am having similar issue. I need to put different lab paramter name on left corner of page and it is different page by page. by variable in proc report doesn't work for me as I can't sort it by parameter. Is there any other way I can create only parameter name ? Also is there anyway I can create variable or can use any option in compute after or break after statement  which will leave blank space after every 5 lines? Really Appreciate your help.

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation