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;
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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.