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:
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.