BookmarkSubscribeRSS Feed
OS2Rules
Obsidian | Level 7

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;

1 REPLY 1
Cynthia_sas
Diamond | Level 26

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1044 views
  • 0 likes
  • 2 in conversation