<?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: Overlapping 2 histograms, using the same scale. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Overlapping-2-histograms-using-the-same-scale/m-p/101334#M28441</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;If you see this post:&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="7152" __jive_macro_name="thread" class="jive_macro jive_macro_thread" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;it should do exactly what you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You first need to calculate the mean, save the mean values in a macro variable (unless you want to hard code them), and use an INSET statement to display the averages.&lt;/P&gt;&lt;P&gt;You could also insert the averages in your legend key, like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means data = temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var ht_m ht_f;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output out = avg mean = ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*save the means in a macro variable that you can later recall;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set avg;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput ("avg_M", put(ht_m,5.1));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput ("avg_F", put(ht_f,5.1));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;title 'Height Distribution';&lt;/P&gt;&lt;P&gt;proc sgplot data=temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; histogram ht_M / fillattrs=graphdata1 name='M' legendlabel=&lt;STRONG&gt;'Avg. Height for Males: &amp;amp;avg_M.'&lt;/STRONG&gt; transparency=0.5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; histogram ht_F / fillattrs=graphdata2 name='F' legendlabel=&lt;STRONG&gt;'Avg. Height for Females: &amp;amp;avg_F'&lt;/STRONG&gt; transparency=0.5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; keylegend 'M' 'F' / location=inside position=topright across=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; xaxis display=(nolabel);&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anca.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Dec 2012 12:21:56 GMT</pubDate>
    <dc:creator>AncaTilea</dc:creator>
    <dc:date>2012-12-18T12:21:56Z</dc:date>
    <item>
      <title>Overlapping 2 histograms, using the same scale.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Overlapping-2-histograms-using-the-same-scale/m-p/101329#M28436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;I am trying to overlap 2 histograms with the same scale. The best I could do so far is to get them adjacently placed but I am not sure how to overlap/superimpose them.&lt;/P&gt;&lt;P&gt;Any advise/help would be highly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is the code for how i placed them next to each other. and attaching the figure for reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background: white;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 12pt; background: white;"&gt;sgpanel&lt;/STRONG&gt; &lt;SPAN style="background: white; color: blue; font-size: 12pt;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-size: 12pt;"&gt;=diabet.EAT_DMNONDM;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-size: 12pt;"&gt;panelby&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-size: 12pt;"&gt; dm ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-size: 12pt;"&gt;histogram&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-size: 12pt;"&gt; eatcm;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-size: 12pt;"&gt;density&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-size: 12pt;"&gt; eatcm;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-size: 12pt;"&gt;title&lt;/SPAN&gt; &lt;SPAN style="background: white; color: purple; font-size: 12pt;"&gt;' EATs compared between DM and NonDM'&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background: white;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks much,&lt;/P&gt;&lt;P&gt;Ashwini&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2012 01:19:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Overlapping-2-histograms-using-the-same-scale/m-p/101329#M28436</guid>
      <dc:creator>Ashwini_uci</dc:creator>
      <dc:date>2012-12-17T01:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Overlapping 2 histograms, using the same scale.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Overlapping-2-histograms-using-the-same-scale/m-p/101330#M28437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ashwini.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think that you need to rearrange your data&amp;nbsp; a bit (a sample data would have helped) to have two different columns (1) eatcm for DM = 1 (something like eatcm_DM) and (2) eatcm for DM = 0 (or eatcm_nonDM)&lt;/P&gt;&lt;P&gt;Then you can use the SGPLOT procedure to do a histogram for eatcm_DM and eatcm_nonDM.&lt;/P&gt;&lt;P&gt;Below is a code that uses the sashelp.class data. In this data set there is a sex variable (M/F) and height.&lt;/P&gt;&lt;P&gt;I want to create an overlay histogram of height for both Male and Females.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this code helps you to adjust your code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*create a height for males and height for females variables;&lt;/P&gt;&lt;P&gt;data temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt; if sex = "F" then ht_F = height;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if sex = "M" then ht_M = height;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;title 'Height Distribution';&lt;/P&gt;&lt;P&gt;proc sgplot data=temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; histogram &lt;STRONG&gt;ht_M&lt;/STRONG&gt; / fillattrs=graphdata1 name='M' legendlabel='Height for Males' transparency=0.5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; histogram &lt;STRONG&gt;ht_F&lt;/STRONG&gt; / fillattrs=graphdata2 name='F' legendlabel='Height for Females' transparency=0.5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; keylegend 'M' 'F' / location=inside position=topright across=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; xaxis display=(nolabel);&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best of luck!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anca.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2012 13:01:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Overlapping-2-histograms-using-the-same-scale/m-p/101330#M28437</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2012-12-17T13:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Overlapping 2 histograms, using the same scale.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Overlapping-2-histograms-using-the-same-scale/m-p/101331#M28438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anca,&lt;/P&gt;&lt;P&gt;Thank you very much for your elaboarate response and the code explaining the histograms overlay.&lt;/P&gt;&lt;P&gt;I rearranged my data and used the code and I could the get a nice histograms overlay.&lt;/P&gt;&lt;P&gt;That was a great help!! I needed it for my presentation. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;Thanks a bunch again..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ashwini&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2012 22:45:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Overlapping-2-histograms-using-the-same-scale/m-p/101331#M28438</guid>
      <dc:creator>Ashwini_uci</dc:creator>
      <dc:date>2012-12-17T22:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Overlapping 2 histograms, using the same scale.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Overlapping-2-histograms-using-the-same-scale/m-p/101332#M28439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My pleasure and best of luck!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2012 23:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Overlapping-2-histograms-using-the-same-scale/m-p/101332#M28439</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2012-12-17T23:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Overlapping 2 histograms, using the same scale.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Overlapping-2-histograms-using-the-same-scale/m-p/101333#M28440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anca,&lt;/P&gt;&lt;P&gt;One more question regarding this post.&lt;/P&gt;&lt;P&gt;I am wondering if you have any idea about how to&amp;nbsp; add or highlight the &lt;SPAN style="text-decoration: underline;"&gt;mean value for EATCM under each histogram?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Thanks much,&lt;/P&gt;&lt;P&gt;Ashwini&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2012 00:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Overlapping-2-histograms-using-the-same-scale/m-p/101333#M28440</guid>
      <dc:creator>Ashwini_uci</dc:creator>
      <dc:date>2012-12-18T00:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Overlapping 2 histograms, using the same scale.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Overlapping-2-histograms-using-the-same-scale/m-p/101334#M28441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;If you see this post:&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="7152" __jive_macro_name="thread" class="jive_macro jive_macro_thread" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;it should do exactly what you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You first need to calculate the mean, save the mean values in a macro variable (unless you want to hard code them), and use an INSET statement to display the averages.&lt;/P&gt;&lt;P&gt;You could also insert the averages in your legend key, like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means data = temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var ht_m ht_f;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output out = avg mean = ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*save the means in a macro variable that you can later recall;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set avg;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput ("avg_M", put(ht_m,5.1));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput ("avg_F", put(ht_f,5.1));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;title 'Height Distribution';&lt;/P&gt;&lt;P&gt;proc sgplot data=temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; histogram ht_M / fillattrs=graphdata1 name='M' legendlabel=&lt;STRONG&gt;'Avg. Height for Males: &amp;amp;avg_M.'&lt;/STRONG&gt; transparency=0.5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; histogram ht_F / fillattrs=graphdata2 name='F' legendlabel=&lt;STRONG&gt;'Avg. Height for Females: &amp;amp;avg_F'&lt;/STRONG&gt; transparency=0.5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; keylegend 'M' 'F' / location=inside position=topright across=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; xaxis display=(nolabel);&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anca.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2012 12:21:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Overlapping-2-histograms-using-the-same-scale/m-p/101334#M28441</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2012-12-18T12:21:56Z</dc:date>
    </item>
  </channel>
</rss>

