BookmarkSubscribeRSS Feed
sunilreddy
Fluorite | Level 6


I am using  title statement each proc report in my program, to make it increment sequence for
number of pages in report i am incrementing number in macro variable (&slideno) by calling below macro for each proc report

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


one of my proc report i am using page break statement. in this, each page break its displaying same title statement in output(

#6A003#SUMMARY - VDP) . 

but i want to use increment number for each break(ex: 003, 004, 005 in 4th position above mentioned title stmt.
how can i use this macro variable increment number to display different title statement for each page break


title  "#6A&slideNo.#SUMMARY - &pot.";

/* increase slide number, must be unique */
%increaseSlideNo;

proc report data=report;

I want output would be in below sequence(003, 004, 005 etc) for each break as high lighted below

#6A003#SUMMARY - VDP; 
#6A004#SUMMARY - VDP;
#6A005#SUMMARY - VDP;

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

Hi:

  This question looks very like some of the other questions that you have already posted on this topic. Alternative code and explanations have been provided for some of your other posts. Have you looked at or tried any of that code? If so, how did that code fail to explain the page breaking behavior and TITLE string behavior?

Similar or related posts that seem to be circling around the same question:

https://communities.sas.com/thread/39028  (code posted here)

https://communities.sas.com/thread/39027 (code posted here)

https://communities.sas.com/thread/38919

https://communities.sas.com/thread/39024 (code posted here about macro resolution)

https://communities.sas.com/thread/39102 (this seems to be a new post that is related to all these others)

  I explained in one of my responses that you can ONLY change a TITLE statement between PROC REPORT steps. So, if you are using the PAGE option on a BREAK statement, the TITLE will NOT change within 1 procedure step, even if you have the PAGE option on a BREAK statement. On the other hand, if you used BY group processing then you could use #BYVAR or #BYVAL in the title to make the title change.

  However, without knowing what your code looks like (as suggested in a previous post), it's hard to provide more concrete advice.

  In addition to relevant code posted at message 39028, there was also code posted at message 39027 that had some more examples of page breaking.

  Again, what is your destination of interest is -- RTF, PDF or HTM? With questions like this, it's very helpful to see a sample of the data and ALL the code (including ODS destination statements), because (for example) you have shown some ODS style overrides in other code snippets that will not work in the LISTING output. So, what is your destination of interest?

  There's no way to tell, from what you've posted, whether the issue is with your PROC REPORT (do you have multiple PROC REPORT statements with a %increaseSlideNo macro call before each one)? How do you know that %SlideNo is changing? How is SlideNo originally set? Is your %LET inside a %DO loop of some kind? How many PROC REPORT steps do you have? When you say that you have a "page break" statement in PROC REPORT what do you mean?? A BREAK statement with the PAGE option or a BY statement? Or both?  PROC REPORT does not have an explicit "PAGE BREAK" statement -- there is only BREAK, RBREAK and BY. Otherwise, for "paged" destinations like RTF and PDF, you will get a page break automatically when the table output hits the bottom margin (less some space for footnotes, if any).

  As a last ditch effort to explain some page break possibilities (both correct and incorrect), compare this single PROC REPORT example (#2 that produces incorrect TITLE statement) with a macro program that generates multiple PROC REPORT steps, each with its own (correct) TITLE statement (#1).

cynthia

%macro change_t(start=11,stop=16);
     
%do age = &start %to &stop;
  title "1) Correct: #6A## Age=&age ##Summary";
    
  proc report data=sashelp.class nowd;
    where age = &age;
  run;
%end;
    
%mend change_t;
    
** Correct TITLE;
ods listing close;
ods html file='c:\temp\changeage.html';
     
%change_t(start=11,stop=13)
    
ods html close;
   
** Incorrect Title, correct LINE;
      
%let age = 11;
ods html file='c:\temp\incorrect_title.html';
  title "2) Title Incorrect: #6A## Age=&age ##Summary";
  title2 "Line Output is Correct";
  proc report data=sashelp.class nowd;
    where age in (11,12,13);
    column age name sex height weight;
    define age / order;
    break after age /page;
    compute before _page_ / style={just=l};
      befline = catx(' ','Line Correct: Age=',put(age,2.0));
      line befline $80.;
    endcomp;
  run;
ods html close;

sunilreddy
Fluorite | Level 6

I am using this proc report code to generate output in stored process, after generated the sequence numbers in title statement, will generate the output in ppt based on sequence numbers in title statement.

i am initiating slideno =1 for first page, slide no is incrementing for each proc report graphs. i.e. for each output object(table or graph) i am giving unique slide number in title.

so during page break, its generating multiple tables, so i want to have different sequence numbers in title statement.After generated #XXnnn## with proper title for each proc report or graph, in this XX is for object type and nnn is for page sequence number. this #XXnnn#  would be useful to sort the objects before generate it in PPT.


data summary_final1;
retain Pgbrk 0 ;
   set summary_final1; 
if mod(_n_ ,25 ) = 1 then pgbrk + 1;
Run;

%let pot = %sysfunc(putc(&vdpId,prdlvlname.));

title  "#6A&slideNo.#SUMMARY - &pot.";

/* increase slide number, must be unique */
%increaseSlideNo;

proc report data=summary_final1 nowd split='#'
    style(report)={rules=none frame=void cellspacing=0pt cellpadding=0pt font_style=roman font_size=8pt font_weight=bold font_face="Arial"}
style(header)={foreground=white background=verydarkblue cellspacing=0pt cellpadding=0pt font_style=roman font_size=8pt font_weight=bold font_face="Arial"}
style(column)={background=white cellspacing=0pt font_size=8pt font_weight=medium font_face="Arial"} split='*';
       ;

    column Pgbrk CUSTOMER_ATTRIB_4_DESC CUSTOMER_NM %end;

         _&prev_year.YY_REQ %do i=1 %to &num_vars1; &&varaa&i %end; _N&curr_year.Y_
         _N&curr_year.&prev_year._YoY %do i=1 %to &num_vars2; &&varba&i %end;;

      define Pgbrk / group noprint;

 
    define CUSTOMER_ATTRIB_4_DESC / group display 'Customer Units' order order=data style=[just=l vjust=t];
    define CUSTOMER_NM / display 'Customer name' style=[just=l vjust=t];

    define _&prev_year.YY_REQ / display  "&prev_year.Y* *REQ"
         style(header)={background=cxeeeeee color=black}
         style(column)={background=cxeeeeee} analysis format=nlnum32.;

   
     %do i=1 %to &num_vars1; 
      define &&varaa&i / display  "&&varac&i* *&&varab&i" analysis format=nlnum32.;
     %end;
 
      define _N&curr_year.Y_ / display  "&curr_year.Y* *REQ + F"
       style(header)={background=cxeeeeee color=black}
       style(column)={background=cxeeeeee} analysis format=nlnum32.;
       
  
   define _N&curr_year.&prev_year._YoY / display  "&prev_year./&curr_year*YoY* "
      style(header)={background=cxbbbbbb color=black}
         style(column)={background=cxbbbbbb} analysis format=nlnum32.;

  %do i=1 %to &num_vars2;
       define &&varba&i / display "&&varbc&i* *F" analysis format=nlnum32.; 
     %end;
   break after pgbrk / page;

      compute CUSTOMER_NM;
  /* Set bold text to last row */
   if CUSTOMER_NM in ("") then
   do;
    call define(_row_,'style','style=[font_weight=bold]');
   end;
  endcomp;
 

   run;

Cynthia_sas
SAS Super FREQ

Hi:

  As I illustrated in my code example, BREAK AFTER PGBRK/PAGE will NOT cause the title to change automatically on every page with a different slide number. If you had multiple PROC REPORTS, with a different TITLE statement for each PROC REPORT, then you could use your Macro variable for each title. Or, if you had a %DO loop, as I illustrated.

  Unless you have multiple PROC REPORT steps with a different TITLE in each, OR you change your approach so that your macro program generates each PROC REPORT with its own TITLE (basically, you would be generating 1 PROC REPORT step for every page) -- the PROC REPORT that you show is not ever going to generate a different title using BREAK AFTER.

  You say that you are "initiating slideno =1 for first page, slide no is incrementing for each proc report graphs. i.e. for each output object(table or graph) i am giving unique slide number in title." I see a macro program invocation that occurs 1 time (a call to
%increaseSlideNo) -- but I only see that 1 time. You say you are doing this in a stored process. If you are executing your stored process multiple times and you want to get a different value for &SlideNo for every invocation, then you will have to use other techniques to make this happen. As I understand stored processes, every stored process invocation gets a fresh, new SAS session, with a fresh, new symbol table. So, unless you persist your session and save your former values for &SlideNo, every invocation of your stored process will probably start out with SlideNo=1, assuming you made the macro variable global and not local. I did not see a CALL SYMPUTX with 'G' option or writing to the global symbol table instead of the local table -- and with stored processes, you probably want to be sure you are putting &SlideNo in the global and not the local table.

 

     Every new TITLE statement in your code replaces a previously issued TITLE statement. A single PROC REPORT step cannot change title statements for every internally generated page break unless you use BY group processing. Every time you invoke a stored process, as a new stored process, the TITLE statements that you use in your stored process code are like new. The title statements from the first invocation of the stored process are not around anymore when the second stored process starts up (unless you have done something to ensure that they are saved).

  You might want to consider working with Tech Support on this. Considering the macro code you're working with, the fact that this is a stored process, and that you seem to want PROC REPORT to operate in a way that is not possible for it to operate, it's hard to put all the separate pieces together to make a coherent suggestion.  Working with a stored process and a macro program invocation in a stored process can change or should change your development approach (such as not having hard coded parameters and using a %GLOBAL statement and not having macro definitions nested within your %STPBEGIN/%STPEND invocations, understanding how you get a fresh symbol table for every stored process invocation, etc, etc. -- To me this needs someone to look at ALL your code and your data and help you figure out whether your current design  is working as you need, from a stored process perspective.

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