I have a survey data which includes these fields: ID, answer, previous_answer. I need the report highlighting the row (or just the 'ID' column) only if 'answer' is different from 'previous_answer'. it works if I just use the 'answer' as 'display' as below: proc report data=mysurvey missing;
column n=cntid answer previous_answer id;
define cntid/noprint;
define id/display;
define answer/display noprint;
define previous_answer/display noprint;
compute id;
if answer ^= previous_answer then
call define(_col_,'STYLE','STYLE=[backgroundcolor=lightred font_weight=bold]');
endcomp;
Compute after / style=[backgroundcolor=lightblue font_weight=bold];
line "Grand Total: " cntid 8.;
endcomp;
run; However, as I need add a 'subtotal' before each 'answer' group, I have to use the 'answer' as an 'order' variable, then the highlight doesn't work: proc report data=mysurvey missing;
column n=cntid answer previous_answer id;
define cntid/noprint;
define id/display;
define answer/order noprint;
define previous_answer/display noprint;
compute id;
if answer ^= previous_answer then
call define(_col_,'STYLE','STYLE=[backgroundcolor=lightred font_weight=bold]');
endcomp;
Compute before answer / style=[font_weight=bold];
if answer=' ' then label_ = '(blank): '; else label_ = strip(answer)||': ';
line label_ $10. cntid 8.;
endcomp;
Compute after / style=[backgroundcolor=lightblue font_weight=bold];
line "Grand Total: " cntid 8.;
endcomp;
run; I attached a dataset I am using for this report. the desired report should only have 'A27' highlighted as it is the only row meets the condition. Thank you in advance!
... View more