<?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 legend labels with group option in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-legend-labels-with-group-option/m-p/299662#M10584</link>
    <description>&lt;P&gt;Did you try with the names of both graphs on the Keylegend statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;keylegend 'act'&amp;nbsp; 'pred';&lt;/P&gt;</description>
    <pubDate>Tue, 20 Sep 2016 20:04:08 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-09-20T20:04:08Z</dc:date>
    <item>
      <title>PROC SGPLOT legend labels with group option</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-legend-labels-with-group-option/m-p/299659#M10583</link>
      <description>&lt;P&gt;I'm trying to make a graph that compares actual to predicted lapse rates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot;
xaxis label='Age' values=(20 to 64 by 2);
yaxis label='Lapse Rate' tickvalueformat=percent6. max=1;
keylegend 'act';
vline age / response=lapse_rate group=dur_grp name='act' legendlabel='Actual Lapse Rate';
vline age / response=pred_rate group=dur_grp lineattrs=(pattern=dash) name='pred' legendlabel='Predicted Lapse Rate';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since I'm using the group= option on the vline statements, the legendlabel= option has no effect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like viewers to know that the solid lines are actual and the dashed lines are predicted.&amp;nbsp; How can I get that information into a legend or a label somehow?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Martin&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 19:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-legend-labels-with-group-option/m-p/299659#M10583</guid>
      <dc:creator>mcs</dc:creator>
      <dc:date>2016-09-20T19:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT legend labels with group option</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-legend-labels-with-group-option/m-p/299662#M10584</link>
      <description>&lt;P&gt;Did you try with the names of both graphs on the Keylegend statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;keylegend 'act'&amp;nbsp; 'pred';&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 20:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-legend-labels-with-group-option/m-p/299662#M10584</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-20T20:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT legend labels with group option</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-legend-labels-with-group-option/m-p/299665#M10585</link>
      <description>&amp;gt;       Did you try with the names of both graphs on the Keylegend statement?&lt;BR /&gt;Yes.  That just doubles the group names, i.e., the legend shows solid lines labeled by the values of the group=variable, and then dashed lines labeled by the same thing.</description>
      <pubDate>Tue, 20 Sep 2016 20:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-legend-labels-with-group-option/m-p/299665#M10585</guid>
      <dc:creator>mcs</dc:creator>
      <dc:date>2016-09-20T20:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT legend labels with group option</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-legend-labels-with-group-option/m-p/299765#M10586</link>
      <description>&lt;P&gt;It would be easier to help if you attach your full program WITH the data so we can see what is going on. &amp;nbsp;Also, provide the SAS release version you are using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, When you use a GROUP role, the unique group values are shown in the legend along with their visual attributes. &amp;nbsp;LEGENDLABEL is ignored. &amp;nbsp;In this case you are using the same GROUP variable, so adding both VLINES to legend will only duplicate the information. &amp;nbsp;If you nave many values for the"dur_grp", using the group variable in two statements will cause use of CYCLEATTRS, and the same group value may get different colors in each statement. &amp;nbsp;Setting NOCYCLEATTRS may retain the same color for each group, but I suggest you use PATTERN=SOLID for the first VLINE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you will have multicolored lines with solid and dash patterns. &amp;nbsp;You need two legends, one for the pattern (for response), and one for the color (for group). &amp;nbsp;You can add these by using some tricks, but there is a better way with SAS 9.4.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have SAS 9.4,&amp;nbsp;you can&amp;nbsp;use the SERIES plot with the GROUP, GROUPLC and GROUPLP options. &amp;nbsp;You will need to change your data, with one response var "Rate" with multiple groups for ID (for each curve), Color (for each group) and Pattern (for each response type). &amp;nbsp;Then, color can represent the "dur_grp" and pattern can represent Lapse or Pred. &amp;nbsp;See blog article on Spaghetti Plot: &amp;nbsp;&lt;A href="http://blogs.sas.com/content/graphicallyspeaking/2014/08/16/more-on-spaghetti-plots/" target="_blank"&gt;http://blogs.sas.com/content/graphicallyspeaking/2014/08/16/more-on-spaghetti-plots/&lt;/A&gt;. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do have multiple obs per age + group, you will need to summarize the data prior to using SGPLOT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 07:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-legend-labels-with-group-option/m-p/299765#M10586</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2016-09-21T07:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT legend labels with group option</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-legend-labels-with-group-option/m-p/299883#M10589</link>
      <description>&lt;P&gt;Thanks.&amp;nbsp; I have 9.4 and&amp;nbsp;was able to get the&amp;nbsp;GROUPLP and GROUPLC options to work for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a couple of questions about fine-tuning the graph.&amp;nbsp; How can I control the colors of the lines?&amp;nbsp; I have three colors in my graph, and the default seems to be blue, red, green.&amp;nbsp; I would prefer red, blue, green in that order.&amp;nbsp; Also, how can I control the entries in the legend?&amp;nbsp; It's currently using the values of the GROUPLP and GROUPLC variables.&amp;nbsp; I would like to specify more easily-readable strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 16:00:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-legend-labels-with-group-option/m-p/299883#M10589</guid>
      <dc:creator>mcs</dc:creator>
      <dc:date>2016-09-21T16:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT legend labels with group option</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-legend-labels-with-group-option/m-p/300028#M10595</link>
      <description>&lt;P&gt;For the color ordering, the most straightforward way to do that is using the STYLEATTRS statement in SGPLOT:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;STYLEATTRS datacontrastcolors=(red blue green);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for the group values, the best way to handle that item is to create user-define formats for those variables using PROC FORMAT and assign the formats to the variables using the FORMAT statement within PROC SGPLOT.&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>Thu, 22 Sep 2016 03:39:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-legend-labels-with-group-option/m-p/300028#M10595</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2016-09-22T03:39:32Z</dc:date>
    </item>
  </channel>
</rss>

