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
SAS Super FREQ

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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