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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.
Ready to level-up your skills? Choose your own adventure.