BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ullsokk
Pyrite | Level 9

 

 

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.   

gannt.PNG

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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:

 

 

Udklip.PNG

View solution in original post

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20

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:

 

 

Udklip.PNG

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 381 views
  • 0 likes
  • 2 in conversation