I am using PROC REPORT to simply print a few state names the a conditional format on the cell color based on the score value. I do not want to print the score value, just the state name. Additionally, I would like to add this output to a panel in PROC TEMPLATE, but see no options for the name to reference it. Is that even possible with this procedure?
proc report data=States nowd ;
columns state_name score;
define state_name/display center ;
define score / noprint;
compute state_name;
if score = 1 then do;
call define(_row_, "style", "style=[font_weight=bold background=BILG]");
end;
if score = 2 then do;
call define(_row_, "style", "style=[font_weight=bold background=gold]");
end;
if score = 3 then do;
call define(_row_, "style", "style=[font_weight=bold background=orange]");
end;
if score = 4 then do;
call define(_row_, "style", "style=[font_weight=bold background=VIYPK]");
end;
endcomp;
run;quit;
I found how to get the formatting to work while suppressing the additional column. Now, I just need a way to get this output assigned to a panel in PROC TEMPLATE.
proc format ;
value colorflag 1='BILG'
2='gold'
3='orange'
4='VIYPK';
run;
proc report data=States nowd out=inset ;
columns state_name score dummy;
define state_name/ 'State Name' display center color=white ;
define score/noprint display;
define dummy/computed noprint;
compute dummy/character length=100;
length svar $100;
if score in( 1, 2, 3, 4) then do;
svar = catt('style={background=', put (score, colorflag.),'}');
dummy=svar;
call define ('state_name', 'style', svar);
end;
endcomp;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.