Is there a way to format data that looks like this:
P-Value |
0.182 |
<0.001 |
0.002 |
I'd like to highlight any cells that have a p-value less than 0.05 and also highlight "<0.001'.
This works below, however I would like to avoid a copy/paste of the statements below and manually type in "0.002". Is there a way to also format for anything <0.05?
compute pvaluen2;
if pvaluen2 ="<0.001" then do;
call define(_col_,'style','style=[background=ltgray]');
end;
Both of these are doable with custom formats.
proc format library=work; value Pback low - <0.05= 'Red' ; value mypval low - <0.001 = '<0.001' other = [best5.] ; run;
In the define block where you want the value highlight use the format instead of a color
style=[background= pback.]
if you want a different color when the the value is larger than 0.05 then add and "other" line to the pback format and the color desired.
And just use format=mypval. for the variable.
You can add as many color ranges as you would like but they cannot overlap. See the syntax for Proc Format on specifying ranges.
Or if the data looks like this:
P-Value |
0.182 |
0.00001 |
0.002 |
Is there a way to format highlightling for values <0.05 and also change 0.00001 to show "<0.001"
Both of these are doable with custom formats.
proc format library=work; value Pback low - <0.05= 'Red' ; value mypval low - <0.001 = '<0.001' other = [best5.] ; run;
In the define block where you want the value highlight use the format instead of a color
style=[background= pback.]
if you want a different color when the the value is larger than 0.05 then add and "other" line to the pback format and the color desired.
And just use format=mypval. for the variable.
You can add as many color ranges as you would like but they cannot overlap. See the syntax for Proc Format on specifying ranges.
data x; input pValue; format pvalue pvalue12.3; cards; 0.182 0.00001 0.002 ; run; compute pvaluen2; if pvaluen2 <0.001 then do; call define(_col_,'style','style=[background=ltgray]'); end;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.