<?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 histogram only one group is displayed if labeld in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-histogram-only-one-group-is-displayed-if-labeld/m-p/572581#M18466</link>
    <description>&lt;P&gt;This works correctly on my version of SAS 9.4M6. What version of SAS are you running?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, you don't need to create the TEST2 data set. Just add the FORMAT statement to PROC SGPLOT:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=test;
   format anaemia yn.;
   histogram Hb / GROUP=anaemia transparency=0.5;
   density Hb / GROUP=anaemia;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jul 2019 01:10:54 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2019-07-11T01:10:54Z</dc:date>
    <item>
      <title>Proc sgplot histogram only one group is displayed if labeld</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-histogram-only-one-group-is-displayed-if-labeld/m-p/572376#M18462</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;this problem is troubling my mind:&lt;/P&gt;&lt;P&gt;I'm creating graphs via sgplot, a histogram with two groups (0&amp;amp;1) displayed in one graph.&amp;nbsp; It works fine, as long as I don't use labels I made via proc template for my group variable. Then one group just disappears. Depending on how I sort my group variable, only the 'yes' or 'no' group is displayed. It's still the same data and the same group variable I put into the graph, it just got a label now. The labels work perfectly fine on different other procs like proc mean.&lt;/P&gt;&lt;P&gt;In the log there is no error message.&lt;/P&gt;&lt;P&gt;There are several scenarios I performed, the problem seems to lie with the histogram, group and label statement.&amp;nbsp;I created dummy data and I experience the same problem there. If the group varibale is a string (yes/no) both groups are displayed. If I use a different graph kind in sgplot, both groups are displayed even if labeld.&lt;/P&gt;&lt;P&gt;My Sas Version is 9.4 (TS1M2)&lt;/P&gt;&lt;P&gt;Below I insert my code, the graphs and in the attachment you can find the dummy data. Anybody got ideas how to solve this? (Other then transforming the group variable into a string)&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;*Graph without labeled group variable;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=test; by anaemia; run;
proc sgplot data=test;
histogram Hb / GROUP=anaemia transparency=0.5;
density Hb / GROUP=anaemia;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;run;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;&lt;BR /&gt;*Creating format;
proc format; value yn 0='No' 1='Yes'; run;
data test2; set test; format anaemia yn.; run;
*Labels work;
proc freq data=test2; table anaemia; run;
*Creating same graph again, only one group is displayed;
proc sort data=test2; by anaemia; run;
proc sgplot data=test2;
histogram Hb / GROUP=anaemia transparency=0.5;
density Hb / GROUP=anaemia;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-right" image-alt="SGPlot2.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30919i704BA4607833D0C7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SGPlot2.png" alt="SGPlot2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-right" image-alt="SGPlot1.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30918i4625CCC09CA39DD9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SGPlot1.png" alt="SGPlot1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 14:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-histogram-only-one-group-is-displayed-if-labeld/m-p/572376#M18462</guid>
      <dc:creator>Magdal3na</dc:creator>
      <dc:date>2019-07-10T14:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sgplot histogram only one group is displayed if labeld</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-histogram-only-one-group-is-displayed-if-labeld/m-p/572581#M18466</link>
      <description>&lt;P&gt;This works correctly on my version of SAS 9.4M6. What version of SAS are you running?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, you don't need to create the TEST2 data set. Just add the FORMAT statement to PROC SGPLOT:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=test;
   format anaemia yn.;
   histogram Hb / GROUP=anaemia transparency=0.5;
   density Hb / GROUP=anaemia;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 01:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-histogram-only-one-group-is-displayed-if-labeld/m-p/572581#M18466</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-07-11T01:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sgplot histogram only one group is displayed if labeld</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-histogram-only-one-group-is-displayed-if-labeld/m-p/572717#M18468</link>
      <description>&lt;P&gt;This problem seems to be version related, I use SAS base, Version 9.4 (TS1M2). Is this a bug I better should report?&lt;/P&gt;&lt;P&gt;Normally I add the format to the exísting data set, just wanted to create a new one for demonstration purpose. Good to know that I can add the format statement in the proc sgplot, didn't know that yet.&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 13:10:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-histogram-only-one-group-is-displayed-if-labeld/m-p/572717#M18468</guid>
      <dc:creator>Magdal3na</dc:creator>
      <dc:date>2019-07-11T13:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sgplot histogram only one group is displayed if labeld</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-histogram-only-one-group-is-displayed-if-labeld/m-p/572737#M18469</link>
      <description>&lt;P&gt;Since the problem has been fixed, I don't think you need to report it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 13:53:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-histogram-only-one-group-is-displayed-if-labeld/m-p/572737#M18469</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-07-11T13:53:02Z</dc:date>
    </item>
  </channel>
</rss>

