The SAS Output Delivery System and reporting techniques

Proc Report Break Problem

Reply
Super Contributor
Posts: 358

Proc Report Break Problem

Hi All.

The following code generates my report correctly with the exception of the "Subtotal" in the compute block.  On the report the value of SEGMENT is printed rather than the word 'Subtotal'.  It works fine for the 'TOTAL' however.  (The style elements come from a template that I didn't include here.)

Any help would be appreciated.

  proc report data=holdings7 nowd split='*' missing;

  column segment mis_group q_d, (holding  rpct)  ('Quarter Over Quarter Change' qoq_v qoq_p);

  define segment       / group     'Segment'                              style(column)=datal;

  define mis_group     / group     'Group'                                style(column)=datal;

  define q_d           / across    ''   order=data;

  define holding       / group sum 'Value'                format=22.2     style(column)=datar [tagattr='format:#,###,###,###,##0.00'];

  define rpct          / group     '%'                    format=$char35. style(column)=datar {tagattr='format:##0.00%'};

  define qoq_v         / computed  'Value'                format=$char15. style(column)=datar [tagattr='format:#,###,###,###,##0.00'];

  define qoq_p         / computed  '%'                    format=$char35. style(column)=datar {tagattr='format:##0.00%'};

  break after segment / summarize;

  rbreak after / summarize;

  compute qoq_v / char;

      qoq_v = '=RC[-2]-RC[-4] ';

  endcomp;

  compute qoq_p / char;

      qoq_p = '=if(RC[-5]=0,0,(RC[-3]/RC[-5])-1) ';

      if _break_ =: '_BREAK_'  then do;

          segment = 'Subtotal';

          mis_group = '';

          end;

      if _break_ =: '_RBREAK_' then do;

          segment = 'TOTAL';

          mis_group = '';

          end;

  endcomp;

SAS Super FREQ
Posts: 8,868

Re: Proc Report Break Problem

Hi:

  I believe you need to change your IF statement. Since you could have multiple BREAK statements, the value of the break variable is the name of the variable controlling the break. Only the break at the end of the report has a value of _RBREAK_. So if your break variable is SEGMENT, then the correct test is:

if upcase(_break_) = 'SEGMENT' .....

and

not if _break_ = '_BREAK_' ....

cynthia

Ask a Question
Discussion stats
  • 1 reply
  • 219 views
  • 0 likes
  • 2 in conversation