BookmarkSubscribeRSS Feed
Calcite | Level 5

Hello, I am using SAS 9.3.  In the code below for a non-grouped chart, I would like to color the bar for "Jane" differently than all the other bars on the graph.  If possible, I would also like to color the marker associated with "Jane" a different color than the other markers.  Also, if possible, I would like to have the tick value of  "Jane" on the xaxis to stand out somehow, maybe bold or different color. If different colors is not an option then how can I place a refline on the xaxis for "Jane".  Basically I need a way to make "Jane" stand out on the graph from all the other names on the xaxis.  My real data is not grouped and the values on the xaxis are text values.

I have tried using an attribute map to change the bar color, but that does not seem to work.  Please see my code below.  Thank you!

data attrmap;

  id='myid'; value='Jane'; fillcolor='orange'; output;


proc sgplot data=sashelp.class


  vbar name / response = height

                    attrid = myid

                    name = 'bar'

                    legendlabel= 'Height';

  vline name /  response = weight

                     name = 'line'

                     legendlabel = 'Weight'



                     markerattrs=(symbol=circlefilled color=mor) 


  xaxis display=(nolabel);

  yaxis grid

           label = 'Height'



           thresholdmax = 1

           thresholdmin = 1; 

  y2axis label = 'Weight'



            thresholdmax = 1

            thresholdmin = 1;


Meteorite | Level 14

You can do this one of two ways.  The simplest one is to create a group column with a name say "ID".  Assign "Jane" to have ID=1, and all others as ID=2.  Then assign GROUP=id in VBar or other statements.  This will also work with overlaid scatters. Colors will come from style.  With SAS 9.4, you can use STYLEATTRS to assign the colors.

Or, you can separate "Jane" into a different variable "Name2", and make "Jne" from initial variable to missing.  Now use two VBAR statements, one fowith Name1, one with Name2.  Now you can assign the specific color (or other) attributes. to each statement.  This will also work with overlaid scatters, you just need two VBars and two Scatters.

Attrmaps work ONLY with groups. There is no way to change just one tick value to have a different color.  But you can use SGAnnotate to do that.


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


Register now!

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
  • 1 like
  • 2 in conversation