I have a task where I need to highlight a cell in an html output if its value falls outside a range (threshold value). The problem is, I have concatenated a value and its %Chg into a single variable for a better representation of the results in an output table. However, I need to highlight the cells based on the threshold values. Since, this new variable is a string (Character) it's not possible (or at least I don't know) to conditional format them on a basis of some numeric value.
diff[i] = comp[i]-base[i];
if base[i] > 0 then
pct_chg[i] = diff[i]/base[i] *100 ;
if pct_chg[i]=. then pct_chg[i]=0;
BASE_C[i] = right(put(diff[i],best.))|| "( " || strip(put(pct_chg[i],best.)) ||" % )";
Difference (%Change) section has columns which I need to format based on a threshold value (see attached). For example, if difference value or PCT value falls outside threshold say 5% then change the cell color to Red. Column "M 201707" under Difference (%Change) is created by using 2 variables,
Where, diff & pct_chg are numeric variables. Is there any way to accomplish this task, may be early in the code or in proc report?
Hi Reeza,
As you have said, I've created ab binary variable ind = ( pct_chg_lst < &pct_threshold.); where &pct_threshold =5 ( say 5% is my threshold. Now, in my proc report when I'm trying to use this binary variable , I am getting variable uninitialized message.
define BASE_C_LAST / " % Chg #" style={cellwidth= 0.60 in};
COMPUTE BASE_C_LAST;
if IND= 0 THEN CALL DEFINE("BASE_C_LAST", "style", "STYLE=[BACKGROUND=LAVENDERBLUSH]");
ENDCOMP;
I am trying to change color of variable BASE_C_LAST based on the value of IND.
Did you remember to define it in your COLUMN statement? And before the column needed - location matters for COMPUTE variables.
@SASFREAK wrote:
Hi Reeza,
As you have said, I've created ab binary variable ind = ( pct_chg_lst < &pct_threshold.); where &pct_threshold =5 ( say 5% is my threshold. Now, in my proc report when I'm trying to use this binary variable , I am getting variable uninitialized message.
define BASE_C_LAST / " % Chg #" style={cellwidth= 0.60 in}; COMPUTE BASE_C_LAST; if IND= 0 THEN CALL DEFINE("BASE_C_LAST", "style", "STYLE=[BACKGROUND=LAVENDERBLUSH]"); ENDCOMP;
I am trying to change color of variable BASE_C_LAST based on the value of IND.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.