<?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 Re: Color difference between two variables PROC SGPLOT in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Color-difference-between-two-variables-PROC-SGPLOT/m-p/894118#M24106</link>
    <description>&lt;P&gt;I am doing something similar for a consort diagram and needing to have boxes that are shaded differently.&amp;nbsp; I discovered that if I created two xy sets then I could label them individually.&amp;nbsp; Not sure if that would work for you here but since I found this while looking for a solution I thought I would include it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data final;&lt;BR /&gt;set box ;&lt;BR /&gt;if subnode in (1,3) then do; x_yellow=xb; y_yellow=yb;end;&amp;nbsp;&lt;BR /&gt;if subnode in (2) then do; x_maize=xb; y_maize=yb;end;&amp;nbsp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ods graphics / reset width=8.5in height=24in noborder;&lt;BR /&gt;proc sgplot data=final noborder noautolegend;&lt;BR /&gt;polygon id=box&amp;nbsp; x=x_yellow y=y_yellow/ fill fillattrs=(color=CxFFC000) outline;&lt;BR /&gt;polygon id=box&amp;nbsp; x=x_maize y=y_maize/ fill fillattrs=(color=CxBF9000) outline;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Sep 2023 16:48:30 GMT</pubDate>
    <dc:creator>Rae_</dc:creator>
    <dc:date>2023-09-13T16:48:30Z</dc:date>
    <item>
      <title>Color difference between two variables PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Color-difference-between-two-variables-PROC-SGPLOT/m-p/242337#M8798</link>
      <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;I'm trying to color the gap between two series charts depending on which of the two y-values is greater.&lt;/P&gt;&lt;P&gt;I colored an example plot in MS Paint, to visualize the idea.&lt;/P&gt;&lt;P&gt;So far I've tried various options in the band statement, but failed. My hope was that the band plot would vanish when the lower values is greater than the upper value. Then I could use two band plots, each with a different filling color. But also that does not work.&lt;/P&gt;&lt;P&gt;Do you have any idea how I could get such a chart in SAS?&lt;/P&gt;&lt;P&gt;Thanks a lot,&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1389i9612D0CFEB6EC6C6/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="Ex2.png" title="Ex2.png" border="0" /&gt;&lt;/P&gt;&lt;P&gt;data temp;&lt;BR /&gt;input x y1 y2;&lt;BR /&gt;datalines;&lt;BR /&gt;1 50 70&lt;BR /&gt;2 60 65&lt;BR /&gt;3 70 50&lt;BR /&gt;4 60 100&lt;BR /&gt;;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sgplot data=temp;&lt;BR /&gt;series x=x y=y1;&lt;BR /&gt;series x=x y=y2;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 07:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Color-difference-between-two-variables-PROC-SGPLOT/m-p/242337#M8798</guid>
      <dc:creator>paulbr</dc:creator>
      <dc:date>2016-01-08T07:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Color difference between two variables PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Color-difference-between-two-variables-PROC-SGPLOT/m-p/242343#M8799</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would probably go down the route of a polygon plot:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/graphicallyspeaking/?s=polygon" target="_blank"&gt;http://blogs.sas.com/content/graphicallyspeaking/?s=polygon&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can draw each polygon with its own color.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 09:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Color-difference-between-two-variables-PROC-SGPLOT/m-p/242343#M8799</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-01-08T09:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Color difference between two variables PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Color-difference-between-two-variables-PROC-SGPLOT/m-p/242368#M8800</link>
      <description>&lt;P&gt;I've actually done something like this before. In my paper, "Secrets of the SG Procedures", I did this plot of a sine wave:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let THRESHOLD = 0;&lt;BR /&gt;data wave;&lt;BR /&gt;do x=-6 to 6 by .05;&lt;BR /&gt;y=sin(x);&lt;BR /&gt;if (y &amp;gt;= &amp;amp;THRESHOLD) then do;&lt;BR /&gt;positive = y;&lt;BR /&gt;negative = &amp;amp;THRESHOLD;&lt;BR /&gt;end;&lt;BR /&gt;else do;&lt;BR /&gt;positive = &amp;amp;THRESHOLD;&lt;BR /&gt;negative = y;&lt;BR /&gt;end;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sgplot data=wave noautolegend;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;yaxis grid label="y";&lt;BR /&gt;&amp;nbsp; &amp;nbsp;xaxis grid;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;band x=x lower=&amp;amp;THRESHOLD&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; upper=positive / transparency=0.5;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;band x=x lower=negative&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; upper=&amp;amp;THRESHOLD /&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; transparency=0.5;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The key to this example is the data manipulation. In a BAND plot, if the upper and lower values are the same, then NOTHING is drawn in that segment. What's trickier about your example is that the y1/y2 invert in places where there is no data. You would need to do some extra work to put data values at those locations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 14:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Color-difference-between-two-variables-PROC-SGPLOT/m-p/242368#M8800</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2016-01-08T14:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Color difference between two variables PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Color-difference-between-two-variables-PROC-SGPLOT/m-p/242373#M8801</link>
      <description>&lt;P&gt;RW9's proposal to use POLYGON will work, but you will need to compute the intersection of the two lines, which may not occur&amp;nbsp;at exact&amp;nbsp;axis value. &amp;nbsp;A partial result is obtained by using one band to wrap back over itself as shown below. &amp;nbsp;You will get the correct filled area. &amp;nbsp;But, now we need to figure out how to color each area differently. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data temp;&lt;BR /&gt;input x y;&lt;BR /&gt;datalines;&lt;BR /&gt;1 50&lt;BR /&gt;2 60&lt;BR /&gt;3 70&lt;BR /&gt;4 60 &lt;BR /&gt;4 100&lt;BR /&gt;3 50&lt;BR /&gt;2 65&lt;BR /&gt;1 70&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sgplot data=temp;&lt;BR /&gt;band x=x upper=y lower=0;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1392i12577B15F384F81E/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Band.png" title="Band.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 14:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Color-difference-between-two-variables-PROC-SGPLOT/m-p/242373#M8801</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2016-01-08T14:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Color difference between two variables PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Color-difference-between-two-variables-PROC-SGPLOT/m-p/894118#M24106</link>
      <description>&lt;P&gt;I am doing something similar for a consort diagram and needing to have boxes that are shaded differently.&amp;nbsp; I discovered that if I created two xy sets then I could label them individually.&amp;nbsp; Not sure if that would work for you here but since I found this while looking for a solution I thought I would include it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data final;&lt;BR /&gt;set box ;&lt;BR /&gt;if subnode in (1,3) then do; x_yellow=xb; y_yellow=yb;end;&amp;nbsp;&lt;BR /&gt;if subnode in (2) then do; x_maize=xb; y_maize=yb;end;&amp;nbsp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ods graphics / reset width=8.5in height=24in noborder;&lt;BR /&gt;proc sgplot data=final noborder noautolegend;&lt;BR /&gt;polygon id=box&amp;nbsp; x=x_yellow y=y_yellow/ fill fillattrs=(color=CxFFC000) outline;&lt;BR /&gt;polygon id=box&amp;nbsp; x=x_maize y=y_maize/ fill fillattrs=(color=CxBF9000) outline;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 16:48:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Color-difference-between-two-variables-PROC-SGPLOT/m-p/894118#M24106</guid>
      <dc:creator>Rae_</dc:creator>
      <dc:date>2023-09-13T16:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: Color difference between two variables PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Color-difference-between-two-variables-PROC-SGPLOT/m-p/894120#M24107</link>
      <description>&lt;P&gt;I've done something similar to this with band plot. Take a look at page 2 of&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings09/324-2009.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings09/324-2009.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 16:54:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Color-difference-between-two-variables-PROC-SGPLOT/m-p/894120#M24107</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2023-09-13T16:54:35Z</dc:date>
    </item>
  </channel>
</rss>

