<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic PROC SGPLOT - changing the marker colors in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-changing-the-marker-colors/m-p/738676#M230460</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if it's possible to change the color of the markers within PROC SGPLOT when you have multiple groups as in the example below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Recep&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA test;&lt;BR /&gt;INPUT Hospital $ age_group $ count;&lt;BR /&gt;CARDS;&lt;BR /&gt;Hosp1 0-16 0&lt;BR /&gt;Hosp1 17-74 10&lt;BR /&gt;Hosp1 75+ 1&lt;BR /&gt;Hosp2 0-16 14&lt;BR /&gt;Hosp3 0-16 1&lt;BR /&gt;Hosp3 17-74 16&lt;BR /&gt;Hosp4 0-16 1&lt;BR /&gt;Hosp4 17-74 4&lt;BR /&gt;Hosp5 17-74 7&lt;BR /&gt;Hosp6 17-74 80&lt;BR /&gt;Hosp6 75+ 2&lt;BR /&gt;Hosp7 17-74 4&lt;BR /&gt;Hosp8 17-74 9&lt;BR /&gt;Hosp9 17-74 95&lt;BR /&gt;Hosp9 75+ 1&lt;BR /&gt;Hosp10 0-16 1&lt;BR /&gt;Hosp10 17-74 27&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;proc sgplot data=test;&lt;BR /&gt;scatter x=hospital y=count/ group=age_group&lt;BR /&gt;grouporder=ascending&lt;BR /&gt;MARKERATTRS=(symbol=circlefilled size=10)&lt;BR /&gt;LEGENDLABEL= "Hospitalizations"&lt;BR /&gt;datalabel&lt;BR /&gt;datalabelpos=top;&lt;/P&gt;&lt;P&gt;xaxis display=all fitpolicy=rotate grid;&lt;BR /&gt;yaxis offsetmin=0.02 grid;&lt;BR /&gt;title ' ';&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Mon, 03 May 2021 18:55:14 GMT</pubDate>
    <dc:creator>Recep</dc:creator>
    <dc:date>2021-05-03T18:55:14Z</dc:date>
    <item>
      <title>PROC SGPLOT - changing the marker colors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-changing-the-marker-colors/m-p/738676#M230460</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if it's possible to change the color of the markers within PROC SGPLOT when you have multiple groups as in the example below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Recep&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA test;&lt;BR /&gt;INPUT Hospital $ age_group $ count;&lt;BR /&gt;CARDS;&lt;BR /&gt;Hosp1 0-16 0&lt;BR /&gt;Hosp1 17-74 10&lt;BR /&gt;Hosp1 75+ 1&lt;BR /&gt;Hosp2 0-16 14&lt;BR /&gt;Hosp3 0-16 1&lt;BR /&gt;Hosp3 17-74 16&lt;BR /&gt;Hosp4 0-16 1&lt;BR /&gt;Hosp4 17-74 4&lt;BR /&gt;Hosp5 17-74 7&lt;BR /&gt;Hosp6 17-74 80&lt;BR /&gt;Hosp6 75+ 2&lt;BR /&gt;Hosp7 17-74 4&lt;BR /&gt;Hosp8 17-74 9&lt;BR /&gt;Hosp9 17-74 95&lt;BR /&gt;Hosp9 75+ 1&lt;BR /&gt;Hosp10 0-16 1&lt;BR /&gt;Hosp10 17-74 27&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;proc sgplot data=test;&lt;BR /&gt;scatter x=hospital y=count/ group=age_group&lt;BR /&gt;grouporder=ascending&lt;BR /&gt;MARKERATTRS=(symbol=circlefilled size=10)&lt;BR /&gt;LEGENDLABEL= "Hospitalizations"&lt;BR /&gt;datalabel&lt;BR /&gt;datalabelpos=top;&lt;/P&gt;&lt;P&gt;xaxis display=all fitpolicy=rotate grid;&lt;BR /&gt;yaxis offsetmin=0.02 grid;&lt;BR /&gt;title ' ';&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 18:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-changing-the-marker-colors/m-p/738676#M230460</guid>
      <dc:creator>Recep</dc:creator>
      <dc:date>2021-05-03T18:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT - changing the marker colors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-changing-the-marker-colors/m-p/738685#M230465</link>
      <description>&lt;P&gt;Do you mean that you want to use specific colors, a different set or something else? The ODS style sets the default colors so changing style changes colors (usually). If you want to override the default color list for that call to the procedure only then that might be the STYLEATTRS statement.&lt;/P&gt;
&lt;P&gt;DATACONTRAST colors affect markers. So you might try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=test;
styleattrs
   datacontrastcolors= (red green blue gold)
;
scatter x=hospital y=count/ group=age_group
grouporder=ascending
MARKERATTRS=(symbol=circlefilled size=10)
LEGENDLABEL= "Hospitalizations"
datalabel
datalabelpos=top;

xaxis display=all fitpolicy=rotate grid;
yaxis offsetmin=0.02 grid;
title ' ';
run;&lt;/PRE&gt;
&lt;P&gt;The typical behavior of most of these procedures is the first value encountered gets the color from the list, the second value the second and so on. So data order can affect color/marker/line type etc.&lt;/P&gt;
&lt;P&gt;If you want a consistent assignment you need to keep data order consistent, which might mean sorting by a group variable.&lt;/P&gt;
&lt;P&gt;Or if you want consistent colors across many procedures you may want to create a DATTRMAP data set.&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 19:31:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-changing-the-marker-colors/m-p/738685#M230465</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-03T19:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT - changing the marker colors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-changing-the-marker-colors/m-p/738719#M230471</link>
      <description>&lt;P&gt;Thank you very much!&amp;nbsp;&lt;/P&gt;&lt;P&gt;styleattrs datacontrastcolors= (red green blue gold); option did exactly what I needed.&lt;/P&gt;&lt;P&gt;I also realized that if VBAR statement is used in the PROC SGPLOT, instead of "datacontrastcolors=(...)", "datacolors=(...)"&amp;nbsp; will do the trick.&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Recep&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 21:36:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-changing-the-marker-colors/m-p/738719#M230471</guid>
      <dc:creator>Recep</dc:creator>
      <dc:date>2021-05-03T21:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT - changing the marker colors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-changing-the-marker-colors/m-p/738739#M230482</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122505"&gt;@Recep&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you very much!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;styleattrs datacontrastcolors= (red green blue gold); option did exactly what I needed.&lt;/P&gt;
&lt;P&gt;I also realized that if VBAR statement is used in the PROC SGPLOT, instead of "datacontrastcolors=(...)", "datacolors=(...)"&amp;nbsp; will do the trick.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Recep&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Part of the fun is finding out which color set goes with which display.&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 23:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-changing-the-marker-colors/m-p/738739#M230482</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-03T23:13:44Z</dc:date>
    </item>
  </channel>
</rss>

