How to add text at the RBREAK level for a numeric GROUP or ORDER variable


In the Listing destination, a numeric GROUP or ORDER variable is set to a blank internally, and there is not a way to override it. In this case, create a COMPUTED variable that is the character version of the numeric GROUP or ORDER variable. Use an IF statement on the automatic _BREAK_ variable to determine whether the row is the _RBREAK_ level, and change the value of the COMPUTED variable.

proc report nowd data=sashelp.class;
   col age newage weight height;
   define age / order noprint;
   define newage / computed format=$8.;
   compute newage / char;
      if age ne . then newage=put(age,$8.);
      else newage=' ';
      if _break_='_RBREAK_' then newage="   total";
   endcomp;
   rbreak after / summarize;
run;


In the ODS destination, determine whether the row is at the _RBREAK_ level by using an IF condition on the automatic _BREAK_ variable. Use a CALL DEFINE statement and the attribute PRETEXT= to print the desired text.

ods rtf file='c:\myrtf.rtf';

proc report nowd data=sashelp.class;
   col age weight height;
   define age / order;
   compute age;
      if _break_='_RBREAK_' then
      call define('age','style','style=[pretext="total"]');
   endcomp;
   rbreak after / summarize;
run;

ods _all_ close;


The above examples modify the row generated by the RBREAK statement. The same logic can be applied to a row generated by a BREAK statement. The value of _BREAK_ is the name of the variable in the BREAK statement.