<?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: SGPLOT KEYLEGEND Problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SGPLOT-KEYLEGEND-Problem/m-p/595449#M171305</link>
    <description>&lt;P&gt;What version of SAS do you use?&lt;/P&gt;</description>
    <pubDate>Thu, 10 Oct 2019 15:22:34 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-10-10T15:22:34Z</dc:date>
    <item>
      <title>SGPLOT KEYLEGEND Problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SGPLOT-KEYLEGEND-Problem/m-p/595446#M171302</link>
      <description>&lt;P&gt;I have the following data.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do groupname="Group 1","Group 2","Group 3";
do i=1 to 100;
x=2*substr(groupname,6)+rannor(1);
output;
end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;As I want to draw a histogram of three groups, I did the following.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot;
histogram x/group=groupname transparency=0.3333;
density x/group=groupname type=kernel;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here's the outcome.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33042i1A54FB2D23823926/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I tried to erase the "groupname" inside the bottom legend box, so used KEYLEGEND as follows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot;
histogram x/group=groupname transparency=0.3333;
density x/group=groupname type=kernel;
keylegend/title="";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And it seems KEYLEGEND unties the items and the outcome repeats these groups twice.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33043i77AE2D5DCF3BC9E8/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;How can I suppress the "groupname" here while avoiding this untying behavior? Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 15:19:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SGPLOT-KEYLEGEND-Problem/m-p/595446#M171302</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-10-10T15:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT KEYLEGEND Problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SGPLOT-KEYLEGEND-Problem/m-p/595449#M171305</link>
      <description>&lt;P&gt;What version of SAS do you use?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 15:22:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SGPLOT-KEYLEGEND-Problem/m-p/595449#M171305</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-10T15:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT KEYLEGEND Problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SGPLOT-KEYLEGEND-Problem/m-p/595454#M171310</link>
      <description>It's 9.4 TS1M5. I found the same at &lt;A href="https://odamid.oda.sas.com/" target="_blank"&gt;https://odamid.oda.sas.com/&lt;/A&gt; too.</description>
      <pubDate>Thu, 10 Oct 2019 15:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SGPLOT-KEYLEGEND-Problem/m-p/595454#M171310</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-10-10T15:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT KEYLEGEND Problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SGPLOT-KEYLEGEND-Problem/m-p/595459#M171315</link>
      <description>&lt;P&gt;You are getting two sets in the legend because the default is to provide a legend for each plot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can request which items to include in the legend by listing the names in the Keylegend statement. Which means that you use the options on the histogram and density statements to name their legend entries.&lt;/P&gt;
&lt;P&gt;Example below should only show the legend for the histogram. Change 'Hist' to 'Dens' to show the density legend.&lt;/P&gt;
&lt;PRE&gt;proc sgplot;
   histogram x/group=groupname transparency=0.3333 name='Hist';
   density x/group=groupname type=kernel name='Dens';
   keylegend  'Hist' /  title=""  ;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Oct 2019 15:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SGPLOT-KEYLEGEND-Problem/m-p/595459#M171315</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-10T15:46:46Z</dc:date>
    </item>
  </channel>
</rss>

