<?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 SGPLOT: fetch colours from another variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SGPLOT-fetch-colours-from-another-variable/m-p/635502#M188697</link>
    <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The below code successfully draws 4 polygons of fill colours red, blue, green, and yellow, respectively.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=MyData aspect=1 noborder nowall noautolegend sganno=MyData subpixel;
  styleattrs datacolors=(&lt;FONT color="#3366FF"&gt;red blue green yellow&lt;/FONT&gt;);
  polygon x=x y=y id=id / fill nooutline group=id;
  xaxis display=none;
  yaxis display=none;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am trying to replace the hardcoded colours by a variable of a different dataset, like so:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  styleattrs datacolors=(&lt;FONT color="#3366FF"&gt;OtherDataSet.colours&lt;/FONT&gt;);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(where OtherDataSet.colours neatly has 4 observations being: red blue green yellow)&lt;/P&gt;&lt;P&gt;However, it fails with the error: "Syntax error, expecting one of the following: a name, a quoted string."&lt;/P&gt;&lt;P&gt;Is there something obvious I am missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 28 Mar 2020 13:34:52 GMT</pubDate>
    <dc:creator>RedBishop</dc:creator>
    <dc:date>2020-03-28T13:34:52Z</dc:date>
    <item>
      <title>SGPLOT: fetch colours from another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SGPLOT-fetch-colours-from-another-variable/m-p/635502#M188697</link>
      <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The below code successfully draws 4 polygons of fill colours red, blue, green, and yellow, respectively.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=MyData aspect=1 noborder nowall noautolegend sganno=MyData subpixel;
  styleattrs datacolors=(&lt;FONT color="#3366FF"&gt;red blue green yellow&lt;/FONT&gt;);
  polygon x=x y=y id=id / fill nooutline group=id;
  xaxis display=none;
  yaxis display=none;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am trying to replace the hardcoded colours by a variable of a different dataset, like so:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  styleattrs datacolors=(&lt;FONT color="#3366FF"&gt;OtherDataSet.colours&lt;/FONT&gt;);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(where OtherDataSet.colours neatly has 4 observations being: red blue green yellow)&lt;/P&gt;&lt;P&gt;However, it fails with the error: "Syntax error, expecting one of the following: a name, a quoted string."&lt;/P&gt;&lt;P&gt;Is there something obvious I am missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Mar 2020 13:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SGPLOT-fetch-colours-from-another-variable/m-p/635502#M188697</guid>
      <dc:creator>RedBishop</dc:creator>
      <dc:date>2020-03-28T13:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT: fetch colours from another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SGPLOT-fetch-colours-from-another-variable/m-p/635512#M188701</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/317271"&gt;@RedBishop&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/?docsetId=grstatproc&amp;amp;docsetTarget=p1dt33l6a6epk6n1chtynsgsjgit.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p01yqbbadjhpuwn1sspovn6okc3l" target="_blank" rel="noopener"&gt;DATACOLORS= option&lt;/A&gt; requires a&amp;nbsp;&lt;SPAN&gt;space-separated list of colors. So, the solution is to create such a list from &lt;FONT face="courier new,courier"&gt;OtherDataSet.colours&lt;/FONT&gt;, store it in a macro variable and refer to this macro variable in the PROC SGPLOT step:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select colourname into :mycolours separated by ' ' /* replace "colourname" with the appropriate variable name */
from OtherDataSet.colours;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;styleattrs datacolors=(&amp;amp;mycolours);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 28 Mar 2020 14:41:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SGPLOT-fetch-colours-from-another-variable/m-p/635512#M188701</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-03-28T14:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT: fetch colours from another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SGPLOT-fetch-colours-from-another-variable/m-p/635519#M188704</link>
      <description>Fantastic, thank you @FreelanceReinhard</description>
      <pubDate>Sat, 28 Mar 2020 15:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SGPLOT-fetch-colours-from-another-variable/m-p/635519#M188704</guid>
      <dc:creator>RedBishop</dc:creator>
      <dc:date>2020-03-28T15:37:25Z</dc:date>
    </item>
  </channel>
</rss>

