I have a table with the following fields:
Happiness | Income | Happy |
4 | 55000 | Yes |
7 | 90000 | Yes |
-3 | 120000 | No |
8 | 42000 | Yes |
-6 | 17000 | No |
I am trying to create a scatter plot of the results where all Happy="Yes" points show up as blue and all Happy="Red" points show up as red. Unfortunately, my code produces the inverse (happy folks show up as red). How do I specify that SYMBOL1 should be applied to Happy="No" values and SYMBOL2 to Happy="Yes"?
/*Graph results*/ TITLE 'Happiness vs. Income'; SYMBOL1 VALUE=dot HEIGHT=0.3 CO=RED; SYMBOL2 VALUE=dot HEIGHT=0.3 CO=STEEL; PROC GPLOT DATA=PL_H3_DRC_POLS; PLOT Happiness*Income=Happy ; RUN;
Thanks in advance for the help
Hi Hadrien,
I think it will work if you just write COLOR= instead of CO= in your SYMBOL statements. (At least it worked in my SAS session.) CO= is not an alias for COLOR=, but "specifies color for confidence limit lines and area outlines" (documentation).
In GPLOT you do not have this functionality. The Assignments of symbol to value are generally the first VALUE for the variable found is assigned the first Symbol, second to second, etc.
So sort your data by HAPPY so that the value you want to be red is the first value.
Or move over to SGPLOT. With SAS 9.3 they added a feature to assign attributes to values for consistency.
Hi Hadrien,
I think it will work if you just write COLOR= instead of CO= in your SYMBOL statements. (At least it worked in my SAS session.) CO= is not an alias for COLOR=, but "specifies color for confidence limit lines and area outlines" (documentation).
Thanks for the help, I was confused about what CO did. I got it to work using COLOR and changing the order of the SYMBOL variables.
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.