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

Hi,

 

I have SAS 9.4 TS Level 1M2. I was wondering if it was possible to use style attribute references within SGPLOT to specify the color of your markers? This is because I like to use the default SAS colors, and in my "real" example, I have several columns, so I will use several scatter statements.

 

I've been using the following code to try and get light red marker symbols, the second color SAS uses in the grouped data, but this doesn't work. I thought it was possible to achieve in SGPLOT in SAS 9.4? I also wanted to avoid using the code of the color, i.e. cx.......

 

proc sgplot data = sashelp.heart;
  scatter x = height y = weight / markerattrs=(symbol=circlefilled color=GraphData2:contrastcolor);
run;

proc sgplot data = sashelp.heart;
  scatter x = height y = weight / markerattrs=(symbol=circlefilled) filledoutlinedmarkers markerfillattrs=(color=GraphData);
run;

proc sgplot data = sashelp.heart;
  scatter x = height y = weight / markerattrs=(symbol=circlefilled color=GraphData2);
run;

 

The following code, does work in GTL, but I wanted to use SGPLOT for this example.

 


proc template;
  define statgraph lineplot;
    begingraph;
      layout overlay;
        scatterplot x = height y = weight / markerattrs=(symbol=circlefilled color=GraphData2:contrastcolor);
      endlayout;
    endgraph;
  end;
run;

proc sgrender data=sashelp.heart template=lineplot;
run;

 

Thank you in advance for your help.

Kriss

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

By a happy coincidence, I asked @SanjayM this question a few weeks ago and he taught me the trick: You need to specify the GraphDatan attributes  and then specify the overrides:

 

proc sgplot data = sashelp.heart;
  scatter x = height y = weight / markerattrs=GraphData2(symbol=circlefilled);
run;

proc sgplot data = sashelp.heart;
  scatter x = height y = weight / markerattrs=(symbol=circlefilled) filledoutlinedmarkers markerfillattrs=GraphData1;
run;

proc sgplot data = sashelp.heart;
  scatter x = height y = weight / markerattrs=GraphData2(symbol=circlefilled);
run;

View solution in original post

3 REPLIES 3
Rick_SAS
SAS Super FREQ

By a happy coincidence, I asked @SanjayM this question a few weeks ago and he taught me the trick: You need to specify the GraphDatan attributes  and then specify the overrides:

 

proc sgplot data = sashelp.heart;
  scatter x = height y = weight / markerattrs=GraphData2(symbol=circlefilled);
run;

proc sgplot data = sashelp.heart;
  scatter x = height y = weight / markerattrs=(symbol=circlefilled) filledoutlinedmarkers markerfillattrs=GraphData1;
run;

proc sgplot data = sashelp.heart;
  scatter x = height y = weight / markerattrs=GraphData2(symbol=circlefilled);
run;
djrisks
Barite | Level 11

Oh thank you @Rick_SAS, that's the way to do it! 🙂

Rick_SAS
SAS Super FREQ

I'm just the messenger, but you are welcome. The real thanks are for Sanjay who provided the information and syntax.Like you, I had tried everything I could think of.

 

I think our confusion is that the syntax GraphData1:ContrastColor is valid in the GTL.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 1187 views
  • 2 likes
  • 2 in conversation