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

Hey guys,

I was wondering if it is possible to adjust the color of the 'markers' for each grouping:

essentially my data looks as follows:

DateRateforecast_rate
12/31/20121.72_10YrTr
12/31/20131.3_10YrTr
12/31/20141.8_10YrTr
12/31/20152.3_10YrTr
12/31/20120.07_3MoTr
12/31/20130.1_3MoTr
12/31/20140.1_3MoTr
12/31/20150.1_3MoTr

I would like to plot it as follows:

proc sgplot data=endyear_givens2;

  scatter x=forecast_Rate y=rate / group=date;

  run;

This gives me almost exactly what I need: the labels "_10YrTr" and "_3MoTr" on the x-axis with the numbers values labeled on the y axis, and the legend contains dates by marker shape. What I would like that is missing though, is for each year (each marker) to have a separate color, I can't figure out how to do this - if I use the markatts(color=) option it changes all 8 markers' colors, I want to see each year group (so both _3MoTr and _10YrTr markers will be one color for 12/31/2012, and then both _3MoTr and _10YrTr markers will be a different color for 12?31/2013, etc.) - Is This possible?

(I've attached the current sgplot output to perhaps be more clear)

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

In SAS 9.3, this would be trivial. In that release we introduced "attribute map" data sets, where you can associate group values with visual attributes. You can use that data set with SGPLOT, SGPANEL, or SGSCATTER to do exactly what you describe above. To simulate this feature in SAS 9.2, you will need to use a GTL template, and use the INDEX option on the SCATTERPLOT statement to associate a style index to your group values. Then, create a column in your data that you will assign the values 1-N based on your group value. Use this column on the INDEX option in your template. If you need, I can put together an example of this. Just let me know.

Thanks!

Dan

View solution in original post

6 REPLIES 6
DanH_sas
SAS Super FREQ

Normally, the GROUP option affects both the shape and the color of the marker. It appears like the style you're using is giving you this behavior. Try this before your SGPLOT statement and see what you get:

ods html style=listing;

Let me know if that fixes the problem.

Thanks!

Dan

AllSoEasy
Obsidian | Level 7

Thank you for your helpful answer! That gets me halfway there -- They are in different color now which is good, but I still have no way of setting which group gets which color -- I want to manually set the color because I want each point to correspond to other graphs representing data by similar groupings, as it draws attention to a relationship that is bein portrayed in a presentation. Is this possible?

DanH_sas
SAS Super FREQ

What version of SAS do you have?

AllSoEasy
Obsidian | Level 7

9.2 -- Sorry I didn't mention this initially.

DanH_sas
SAS Super FREQ

In SAS 9.3, this would be trivial. In that release we introduced "attribute map" data sets, where you can associate group values with visual attributes. You can use that data set with SGPLOT, SGPANEL, or SGSCATTER to do exactly what you describe above. To simulate this feature in SAS 9.2, you will need to use a GTL template, and use the INDEX option on the SCATTERPLOT statement to associate a style index to your group values. Then, create a column in your data that you will assign the values 1-N based on your group value. Use this column on the INDEX option in your template. If you need, I can put together an example of this. Just let me know.

Thanks!

Dan

AllSoEasy
Obsidian | Level 7

Very interesting...an example won't be necessary, this information is extremely useful and I will be able to take it from here.

Thank you so much!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1792 views
  • 3 likes
  • 2 in conversation