<?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: PROC SGPLOT SERIES: Colour markers by variable values in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359334#M12514</link>
    <description>&lt;P&gt;Please avoid coding all in uppper case, it makes reading your code so much harder.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I was doing this, I would split out the three data items, so the data in orange goes in one column, the green in another, and all the rest in a third.&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=hc2016 (where=(date=&amp;amp;d));
  xaxis values=(&amp;amp;start to &amp;amp;finish by minute) interval=minute;
  series x=dt y=volume / legendlabel="volume";
  series x=dt y=close_grey / y2axis legendlabel="Close Price" datalabel=signal markers markerattrs=(color=grey);
  series x=dt y=close_orange / y2axis datalabel=signal markers markerattrs=(color=orange);
  series x=dt y=close_green / y2axis datalabel=signal markers markerattrs=(color=green);
run;&lt;/PRE&gt;</description>
    <pubDate>Wed, 17 May 2017 10:54:56 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-05-17T10:54:56Z</dc:date>
    <item>
      <title>PROC SGPLOT SERIES: Colour markers by variable values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359322#M12511</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some stock market data that I've put on a graph.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SGPLOT DATA=HC2016 (WHERE=(Date=&amp;amp;d));
	XAXIS VALUES=(&amp;amp;start TO &amp;amp;finish BY MINUTE) INTERVAL=MINUTE;
	SERIES X=DT Y=Volume / LEGENDLABEL="Volume";
	SERIES X=DT Y=Close / Y2AXIS LEGENDLABEL="Close Price" DATALABEL=Signal markers;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My Signal Variable has the following values: 0 (Orange Signal), 1 (Low Return), 2 (High return), 10 (Green Signal)&lt;/P&gt;&lt;P&gt;I would like to know how to colour the markers by Signal values. I want the "Orange Signal" value to be orange, the "Green Signal" value to be green and everything in between to be grey.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I change my syntax?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, how do I change the F6 and F7 values with Volume and Close Price?&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13847i62EEAF3568FCC6F9/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Capture.JPG" title="Capture.JPG" /&gt;</description>
      <pubDate>Wed, 17 May 2017 10:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359322#M12511</guid>
      <dc:creator>Elle</dc:creator>
      <dc:date>2017-05-17T10:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT SERIES: Colour markers by variable values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359325#M12512</link>
      <description>&lt;P&gt;It would be easier to help if we could see some of your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I believe you can do this by adding&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;styleattrs datacontrastcolors=(orange green grey);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;right below your proc sgplot statement and grouping by Signal&amp;nbsp;in your series options after the forward slash as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;group = Signal&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 10:55:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359325#M12512</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-05-17T10:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT SERIES: Colour markers by variable values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359333#M12513</link>
      <description>STYLEATTRS gives an error.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, ASPECT, CYCLEATTRS, DATA, DATTRMAP, DESCRIPTION, NOAUTOLEGEND,&lt;BR /&gt;NOBORDER, NOCYCLEATTRS, NOOPAQUE, NOSUBPIXEL, NOWALL, OPAQUE, PAD, PCTLEVEL, PCTNDEC, RATTRMAP, SGANNO, SUBPIXEL,&lt;BR /&gt;TMPLOUT, UNIFORM.</description>
      <pubDate>Wed, 17 May 2017 10:54:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359333#M12513</guid>
      <dc:creator>Elle</dc:creator>
      <dc:date>2017-05-17T10:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT SERIES: Colour markers by variable values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359334#M12514</link>
      <description>&lt;P&gt;Please avoid coding all in uppper case, it makes reading your code so much harder.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I was doing this, I would split out the three data items, so the data in orange goes in one column, the green in another, and all the rest in a third.&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=hc2016 (where=(date=&amp;amp;d));
  xaxis values=(&amp;amp;start to &amp;amp;finish by minute) interval=minute;
  series x=dt y=volume / legendlabel="volume";
  series x=dt y=close_grey / y2axis legendlabel="Close Price" datalabel=signal markers markerattrs=(color=grey);
  series x=dt y=close_orange / y2axis datalabel=signal markers markerattrs=(color=orange);
  series x=dt y=close_green / y2axis datalabel=signal markers markerattrs=(color=green);
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 May 2017 10:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359334#M12514</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-17T10:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT SERIES: Colour markers by variable values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359335#M12515</link>
      <description>&lt;P&gt;Shouldn't yield an error if it is placed correctly as in this example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data = sashelp.iris;
styleattrs datacontrastcolors=(orange green grey);
scatter x = sepallength y = sepalwidth / group = species;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 May 2017 10:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359335#M12515</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-05-17T10:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT SERIES: Colour markers by variable values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359336#M12516</link>
      <description>The data is a simple stock market data with a date variable, volume and close price. My Signal variable is a simple numeric variable =( . , 0 , 1 , 2 , 10 ) with a format attached to it. It is supposed to highlight important changes in Close Price.</description>
      <pubDate>Wed, 17 May 2017 10:59:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359336#M12516</guid>
      <dc:creator>Elle</dc:creator>
      <dc:date>2017-05-17T10:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT SERIES: Colour markers by variable values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359338#M12517</link>
      <description>&lt;P&gt;Ok, I thought those were PROC SGPLOT options. My mystake.&lt;/P&gt;&lt;P&gt;The resulting graph looks weird however.&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13848i649D991FCFCADF1F/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Capture2.JPG" title="Capture2.JPG" /&gt;</description>
      <pubDate>Wed, 17 May 2017 11:03:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359338#M12517</guid>
      <dc:creator>Elle</dc:creator>
      <dc:date>2017-05-17T11:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT SERIES: Colour markers by variable values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359339#M12518</link>
      <description>This wouldn't work, as I need the Close Price on Y2. I did post a photo on how my graph looks like. I'm happy with the way it looks. I just want the writing for Orange Signal/Green Signal/Low Return/High Return to have different colours and different coloured markers</description>
      <pubDate>Wed, 17 May 2017 11:07:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359339#M12518</guid>
      <dc:creator>Elle</dc:creator>
      <dc:date>2017-05-17T11:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT SERIES: Colour markers by variable values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359341#M12519</link>
      <description>&lt;P&gt;I edited my graph in Paint to show how I want it to look like (attached)&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13849i84E02281ADF9700A/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="desired_result.JPG" title="desired_result.JPG" /&gt;</description>
      <pubDate>Wed, 17 May 2017 11:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359341#M12519</guid>
      <dc:creator>Elle</dc:creator>
      <dc:date>2017-05-17T11:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT SERIES: Colour markers by variable values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359356#M12520</link>
      <description>&lt;P&gt;Sorry, your not making much sense. &amp;nbsp;This has nothing to do with axis. &amp;nbsp;The point is to do:&lt;/P&gt;
&lt;P&gt;1) draw your graph all the as you have now, and exclude the two items you want to have in a nother color. &amp;nbsp;Then to this code you add another two plots to add these points in and apply the color. &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=hc2016 (where=(date=&amp;amp;d));
  xaxis values=(&amp;amp;start to &amp;amp;finish by minute) interval=minute;&lt;BR /&gt;/* This creates the other line plot */
  series x=dt y=volume / legendlabel="volume";&lt;BR /&gt;/* This creates the line plot you currently have - the y variable should contain only those poits you want in grey */
  series x=dt y=close_grey / y2axis legendlabel="Close Price" datalabel=signal markers markerattrs=(color=grey);&lt;BR /&gt;/* This creates another overlay which should only have the one point for the orange (note you could also use scatter here) */
  series x=dt y=close_orange / y2axis datalabel=signal markers markerattrs=(color=orange);&lt;BR /&gt;/* This creates another overlay which should only have the one point for the green (note you could also use scatter) */
  series x=dt y=close_green / y2axis datalabel=signal markers markerattrs=(color=green);
run;&lt;/PRE&gt;
&lt;P&gt;So plots as you have, then overlay that with the 1 point plot of the orange value, and then overlay again the one point plot of the green value.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 12:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359356#M12520</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-17T12:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT SERIES: Colour markers by variable values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359380#M12521</link>
      <description>&lt;P&gt;I don't know how to explain it in a simpler way. I want to highlight some points on the price series with different colours.&lt;/P&gt;&lt;P&gt;I want to graph the Price and then overlay the points found in Signal variable. I want to highlight on the price series when an orange signal is given (orange dot), I want to show the significant spikes in prices (grey dots) and then finish with a green signal (green dot) to show the price has stabilized.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code gives me the attached result.&lt;/P&gt;&lt;P&gt;...I've attached a sample of data, maybe it will become clearer why this code won't work.&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13851i7DD3D72375E463A7/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Res.JPG" title="Res.JPG" /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13852i3C6F9B49AF848164/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="sample.JPG" title="sample.JPG" /&gt;</description>
      <pubDate>Wed, 17 May 2017 14:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359380#M12521</guid>
      <dc:creator>Elle</dc:creator>
      <dc:date>2017-05-17T14:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT SERIES: Colour markers by variable values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359390#M12522</link>
      <description>&lt;P&gt;We ask for test data in the form of a datastep, I don't have time to type all that in. &amp;nbsp;As such I am again guessing if this works, but it should:&lt;/P&gt;
&lt;PRE&gt;data updated;
  set hc2016;
  close_orange=ifn(signal="Orange Signal",close,.);
  close_green=ifn(signal="Green Signal",close,.);
run;
/* What the above gives you is a dataset with your original data - as per your output as you want it now
   with two additional variables which hold the data needed to plot a point for the green marker and
   a point for the orrange marker*/

proc sgplot data=updated (where=(date=&amp;amp;d));
	xaxis values=(&amp;amp;start to &amp;amp;finish by minute) interval=minute;
	series x=dt y=volume / legendlabel="volume";
	series x=dt y=close / y2axis legendlabel="Close Price" datalabel=signal markers;
  /* Now we add to rows to overlay the colored point */
  scatter x=dt y=close_orange / y2axis markerattrs=(color=orange);
  scatter x=dt y=close_green / y2axis markerattrs=(color=green);
run;&lt;/PRE&gt;
&lt;P&gt;The above should replicate what you have now, plus adding two points at the green and orange points.&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 14:24:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359390#M12522</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-17T14:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT SERIES: Colour markers by variable values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359397#M12523</link>
      <description>&lt;P&gt;Here is a basic outline that will give you complete&amp;nbsp;control:&lt;/P&gt;
&lt;P&gt;1. Create a separate data set that contains the dates of interest, along with the labels to display.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Concatenate the data with the &amp;nbsp;data set in (1).&lt;/P&gt;
&lt;P&gt;3. Use the SERIES statement for the lines plots, and the STYLEATTRS and the SCATTER statement for the special points.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example for you to study. It uses data that we can all access. You can use this data in the future for additional questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data stocks;
set sashelp.stocks;
where stock="IBM" AND year(date) &amp;lt;= 1994;
run;

data SpecialPoints;
 Signal=0; x='03Aug1987'd; y=168.38;text="Green Signal "; output;
 Signal=1; x='01Sep1993'd; y=42;    text="Orange Signal"; output;
 Signal=2; x='01JUN1992'd; y=97.87 ;text="Gray Signal  "; output;
run;

data all;
set stocks SpecialPoints;
run;

proc sgplot data=all noautolegend;
styleattrs datacontrastcolors=(orange green grey);
series x=date y=volume;
series x=date y=close / y2axis lineattrs=(color=brown);
scatter x=x y=y / y2axis group=Signal datalabel=text
        markerattrs=(size=18 symbol=CircleFilled);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 May 2017 14:45:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359397#M12523</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-05-17T14:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT SERIES: Colour markers by variable values</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359399#M12524</link>
      <description>&lt;P&gt;RW9 solution should work fine; but, alternative option would be to use an attributes map. This approach would require no data manipulation in this case. The code would look something like the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data attrmap;
retain id "myid" markersymbol "circlefilled";
length value $ 13 markercolor $ 6;
input value $ 1-13 markercolor $;
cards;
Orange Signal orange
Low Return      gray
High Return     gray
Green Signal   green
;
run;

proc sgplot data=updated (where=(date=&amp;amp;d)) dattrmap=attrmap;
	xaxis values=(&amp;amp;start to &amp;amp;finish by minute) interval=minute;
	series x=dt y=volume / legendlabel="volume" name="V";
	series x=dt y=close / y2axis legendlabel="Close Price" datalabel=signal markers name="C";
  /* Now we add to rows to overlay the colored point */
  scatter x=dt y=close / y2axis group=signal attrid=myid name="signal";
  keylegend "V" "C" / position=bottomlleft;
  keylegend "signal" / position=bottomright;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 14:55:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-SERIES-Colour-markers-by-variable-values/m-p/359399#M12524</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2017-05-17T14:55:51Z</dc:date>
    </item>
  </channel>
</rss>

