Proc Format for traffic lighting not working

157 views Asked by At

I am attempting to create traffic lighting in a report using proc format. But even though the values can be greater than 1 or below 1 the colors are always the lowest color. In this case, they are all red. Why is SAS not seeing the values?

proc format; 
value forecast 
   low - < 0.70 = 'red'
   0.70 - <0.90 = 'yellow'
   0.90 - high = 'green';
run;

%macro perform_target  (cc, year, career_id, cc_name) ;

data Performance_&career_id._&cc._&year. ;
    set post_target_comparisons1;
    where institution = "&cc." and year = "&year." and career_id = "&career_id.";
run;

ods excel file = "Y:\General - CTE\2019 CTE Accountability\2020\Need Assessment Performance 
Tables\Performance_&career_id._&cc._&year..xlsx" style = sasdocprinter;

    ods excel options(autofilter="2-39" sheet_name = "Performance &year." embedded_titles = 'yes'); 
    run;

    title j= C "Actual to Target Comparisons";
    title2 j = C "Academic Year - &year.";
    run;

    proc report data = Performance_&career_id._&cc._&year.;

    column community_college cluster_label measure_label year total_students total_male percent_male 
    target forecast_male forecast_female forecast_AI forecast_AS forecast_AA forecast_HI forecast_PI 
    forecast_W forecast_MU forecast_disabled forecast_farms forecast_single forecast_displaced 
    forecast_ell forecast_nontrad;

     define forecast_male/display 'Percent to Forecast Male' style(column) = [cellwidth=1in 
     tagattr="format:####.##\%" fontweight = bold foreground = forecast.];

     run;

    ods excel close;

    %mend perform_target;

    %perform_target (010042, 2016, 01);
1

There are 1 answers

1
data _null_ On

This works so I expect your data is the issue.

proc format; 
   value forecast 
      low - < 0.70 = 'red'
      0.70 - <0.90 = 'yellow'
      0.90 - high = 'green';
   run;

data have;
   do x = 0 to 1 by .05;
      output;
      end;
   run;
ods excel file='test.xlsx';
proc report data=have list;
   columns x;
   define x / display /*format=percent12.2*/ style(column)=[cellwidth=1in tagattr="format:####.##\%" fontweight = bold foreground = forecast.];
   run;
ods excel close;