<?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: Hbar + Scatter + Annotations? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Hbar-Scatter-Annotations/m-p/770335#M22013</link>
    <description>Look at the KEYLEGEND statement to have control over the legend via SGPLOT.</description>
    <pubDate>Fri, 24 Sep 2021 18:19:47 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-09-24T18:19:47Z</dc:date>
    <item>
      <title>Hbar + Scatter + Annotations?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Hbar-Scatter-Annotations/m-p/768955#M22001</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having an issue with a graph that consists of Hbar, Scatter, and Annotations. To simplify the issue, I've created sample data as follows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test1;&lt;BR /&gt;length name run1_stop run2_stop $ 50;&lt;BR /&gt;name = "Bob";&amp;nbsp;team = "Team AAA";&amp;nbsp;run1 = 10;&amp;nbsp;run2 = 6;&amp;nbsp;run1_stop = "Need Water";&amp;nbsp;run2_stop = "Need Rest";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test2;&lt;BR /&gt;length name run1_stop run2_stop $ 50;&lt;BR /&gt;name = "Bill";&amp;nbsp;team = "Team AAA";&amp;nbsp;run1 = 8;&amp;nbsp;run2 = 13;&amp;nbsp;run1_stop = "Need Rest";&amp;nbsp;run2_stop = "Need Water";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data final;&lt;BR /&gt;set test1 test2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dd.PNG" style="width: 586px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63838iC218B41FC811F76C/image-size/large?v=v2&amp;amp;px=999" role="button" title="dd.PNG" alt="dd.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is to create a bar graph with the following:&lt;/P&gt;&lt;P&gt;-X-axis = Name of runner.&lt;/P&gt;&lt;P&gt;-Y-axis = Distance ran.&lt;/P&gt;&lt;P&gt;-Annotations to show run1 vs run2.&lt;/P&gt;&lt;P&gt;-Markers to show why the run ended (via scatter plots). These must be consistent throughout the entire graph. Ie if a runner stopped due to "Need Rest," then the marker used should be the same for all runners and every run (run1, run2, etc).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I've using the following relevant lines of code with Proc Sgplot:&lt;/P&gt;&lt;P&gt;(1)&amp;nbsp;hbarparm category = name response = run1 /&amp;nbsp;discreteoffset = -0.065&lt;/P&gt;&lt;P&gt;(2)&amp;nbsp;hbarparm category = name response = run2 /&amp;nbsp;discreteoffset = 0.065&lt;/P&gt;&lt;P&gt;(3)&amp;nbsp;scatter x = run1 y = name / group = run1_stop&amp;nbsp;discreteoffset = -0.065;&lt;/P&gt;&lt;P&gt;(4)&amp;nbsp;scatter x = run2 y = name / group = run2_stop discreteoffset = 0.065;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is what I'm getting:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="p1.PNG" style="width: 879px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63836i1CA48EDC423FB7F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="p1.PNG" alt="p1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I would like (created using MS Paint):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="p2.PNG" style="width: 873px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63839iF4E74ECFAD2F025B/image-size/large?v=v2&amp;amp;px=999" role="button" title="p2.PNG" alt="p2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this something that can be done using SAS graphics?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any assistance!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Sep 2021 21:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Hbar-Scatter-Annotations/m-p/768955#M22001</guid>
      <dc:creator>snapbolt</dc:creator>
      <dc:date>2021-09-21T21:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Hbar + Scatter + Annotations?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Hbar-Scatter-Annotations/m-p/768970#M22002</link>
      <description>You need to restructure your data for starters, put each run on it's own line and add an indicator that is for run1/run2 then pipe that to the datalabel option on the hbar/hbarparm statement. That will get you the labels. &lt;BR /&gt;&lt;BR /&gt;For the points, similar idea, use a scatter statement with the value of the Distance to get the same chart, with one variable for Water/Rest as well.</description>
      <pubDate>Tue, 21 Sep 2021 22:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Hbar-Scatter-Annotations/m-p/768970#M22002</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-21T22:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Hbar + Scatter + Annotations?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Hbar-Scatter-Annotations/m-p/770094#M22004</link>
      <description>&lt;P&gt;Appreciate the advice. I modified the data to be "longer." Below is the complete code I used to generate the dummy data. Pardon the lack of indents. Copying / Pasting from notepad seems to eliminate the indents.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, I was able to get most of what I wanted in the graph. But it's still not complete.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test1;&lt;BR /&gt;length name team run1_stop run2_stop $ 50;&lt;BR /&gt;name = "Bob";&lt;BR /&gt;team = "Team AAA";&lt;BR /&gt;run1 = 10;&lt;BR /&gt;run2 = 6;&lt;BR /&gt;run1_stop = "Need Water";&lt;BR /&gt;run2_stop = "Need Rest";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test2;&lt;BR /&gt;length name team run1_stop run2_stop $ 50;&lt;BR /&gt;name = "Bill";&lt;BR /&gt;team = "Team AAA";&lt;BR /&gt;run1 = 8;&lt;BR /&gt;run2 = 13;&lt;BR /&gt;run1_stop = "Need Rest";&lt;BR /&gt;run2_stop = "Need Water";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data final;&lt;BR /&gt;set test1 test2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data run1;&lt;BR /&gt;set final;&lt;BR /&gt;team = strip (team) || " - Run 1";&lt;BR /&gt;run_race = "Run 1";&lt;BR /&gt;run_label = "Run 1";&lt;BR /&gt;run_stop = run1_stop;&lt;BR /&gt;run_time = run1;&lt;BR /&gt;keep name team run_label run_time run_stop;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data run2;&lt;BR /&gt;set final;&lt;BR /&gt;team = strip (team) || " - Run 2";&lt;BR /&gt;run_race = "Run 2";&lt;BR /&gt;run_label = "Run 2";&lt;BR /&gt;run_stop = run2_stop;&lt;BR /&gt;run_time = run2;&lt;BR /&gt;keep name team run_label run_time run_stop;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data final2;&lt;BR /&gt;set run1 run2;&lt;BR /&gt;if run_label = "Run 1" and run_stop = "Need Water" then run1_need_water = "Need Water";&lt;BR /&gt;else if run_label = "Run 2" and run_stop = "Need Water" then run2_need_water = "Need Water";&lt;BR /&gt;if run_label = "Run 1" and run_stop = "Need Rest" then run1_need_rest = "Need Rest";&lt;BR /&gt;else if run_label = "Run 2" and run_stop = "Need Rest" then run2_need_rest = "Need Rest";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="snapbolt_0-1632450408855.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64020i6B88433995D71DFB/image-size/large?v=v2&amp;amp;px=999" role="button" title="snapbolt_0-1632450408855.png" alt="snapbolt_0-1632450408855.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the graphing part, I did the following:&lt;/P&gt;&lt;P&gt;(1)&amp;nbsp;hbarparm category = name response = run_time /&amp;nbsp;group = team&lt;/P&gt;&lt;P&gt;(2)&amp;nbsp;scatter x = run_time y = name /&amp;nbsp;group = run1_need_water ...&amp;nbsp;symbol=trianglefilled&amp;nbsp;discreteoffset = -0.05;&lt;/P&gt;&lt;P&gt;(3)&amp;nbsp;scatter x = run_time y = name /&amp;nbsp;group = run2_need_water ...&amp;nbsp;symbol=trianglefilled&amp;nbsp;discreteoffset = 0.05;&lt;/P&gt;&lt;P&gt;(4)&amp;nbsp;scatter x = run_time y = name /&amp;nbsp;group = run1_need_rest ... symbol=squarefilled&amp;nbsp;discreteoffset = -0.05;&lt;/P&gt;&lt;P&gt;(5)&amp;nbsp;scatter x = run_time y = name /&amp;nbsp;group = run2_need_rest ... symbol=squarefilled&amp;nbsp;discreteoffset = 0.05;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The final graph looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="snapbolt_3-1632451077982.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64023iFEB6B6DA466A1EA3/image-size/large?v=v2&amp;amp;px=999" role="button" title="snapbolt_3-1632451077982.png" alt="snapbolt_3-1632451077982.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The remaining issue is with the legend. I need the marked section to look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="snapbolt_4-1632451216828.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64024i043C09F1419FEFDA/image-size/large?v=v2&amp;amp;px=999" role="button" title="snapbolt_4-1632451216828.png" alt="snapbolt_4-1632451216828.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll have to investigate this a little more. Appreciate any ideas or recommendations for this issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Quick side note:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had to create a unique variable for water / rest for each run. Otherwise the table would have the same marker for rest and water, and the markers wouldn't line up with the individual hbar's.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="snapbolt_2-1632450781627.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64022i12FAD55B59646DC2/image-size/large?v=v2&amp;amp;px=999" role="button" title="snapbolt_2-1632450781627.png" alt="snapbolt_2-1632450781627.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="snapbolt_1-1632450754322.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64021i0F8EA51722A0AF06/image-size/large?v=v2&amp;amp;px=999" role="button" title="snapbolt_1-1632450754322.png" alt="snapbolt_1-1632450754322.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 02:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Hbar-Scatter-Annotations/m-p/770094#M22004</guid>
      <dc:creator>snapbolt</dc:creator>
      <dc:date>2021-09-24T02:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Hbar + Scatter + Annotations?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Hbar-Scatter-Annotations/m-p/770335#M22013</link>
      <description>Look at the KEYLEGEND statement to have control over the legend via SGPLOT.</description>
      <pubDate>Fri, 24 Sep 2021 18:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Hbar-Scatter-Annotations/m-p/770335#M22013</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-24T18:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Hbar + Scatter + Annotations?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Hbar-Scatter-Annotations/m-p/770651#M22024</link>
      <description>&lt;P&gt;I found the solution and got the final graph that I wanted. It wasn't as straightforward as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone would like the dummy data and the final code, please let me know. It's a bit too long to post here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, all!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Sep 2021 15:07:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Hbar-Scatter-Annotations/m-p/770651#M22024</guid>
      <dc:creator>snapbolt</dc:creator>
      <dc:date>2021-09-27T15:07:56Z</dc:date>
    </item>
  </channel>
</rss>

