BookmarkSubscribeRSS Feed
RandoDando
Pyrite | Level 9

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;

 

1 REPLY 1
RandoDando
Pyrite | Level 9

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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 442 views
  • 0 likes
  • 1 in conversation