I want my gannt chart lines to have a color corresponding to the amount variable, akin to microsoft excel's conditional formatting. I want higher values to be red, average to be yellow and low values to be green, preferrably with gradings in between. Is there a way to colorize each line automatically based on the amount value? My real data contains hundreds of cases, so I dont want a hardcoded sollution.
Here is my code:
DATA have;
INPUT id $ amount start_dt end_dt ;
CARDS;
1 5000 21000 21030
2 30000 20870 20999
3 200 20951 21000
4 10000 20942 20987
5 500 20820 20900
;
RUN;
data have ;
set have ;
format start_dt end_dt date9.;
run;
ods graphics on ;
proc sgplot data=have noautolegend;
highlow y=id low=start_dt high=end_dt/
lineattrs=(thickness=6pt);
yaxis grid reverse ;
run;
Something like this?
proc sgplot data=have noautolegend;
highlow y=id low=start_dt high=end_dt/
lineattrs=(thickness=6pt) colorresponse=Amount colormodel=(green gold red);
gradlegend / position=right;
yaxis grid reverse;
run;
Result:
Something like this?
proc sgplot data=have noautolegend;
highlow y=id low=start_dt high=end_dt/
lineattrs=(thickness=6pt) colorresponse=Amount colormodel=(green gold red);
gradlegend / position=right;
yaxis grid reverse;
run;
Result:
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.