<?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: Multiple Histograms/Densities on same graph? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12571#M250</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can call R from PROC IML and from SAS/IML Studio.&lt;/P&gt;&lt;P&gt;For a video that shows the basics, see &lt;A href="http://blogs.sas.com/content/iml/2011/10/31/video-calling-r-from-the-sasiml-language/" title="http://blogs.sas.com/content/iml/2011/10/31/video-calling-r-from-the-sasiml-language/"&gt; Video: Calling R from the SAS/IML Language - The DO Loop&lt;/A&gt; &lt;/P&gt;&lt;P&gt;For an example and discussion, see &lt;A href="http://blogs.sas.com/content/iml/2011/05/13/calling-r-from-sasiml-software/" title="http://blogs.sas.com/content/iml/2011/05/13/calling-r-from-sasiml-software/"&gt; Calling R from SAS/IML software - The DO Loop&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Feb 2013 18:22:25 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2013-02-21T18:22:25Z</dc:date>
    <item>
      <title>Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12549#M228</link>
      <description>Hi All&lt;BR /&gt;
&lt;BR /&gt;
I am trying to figure out the best way to get multiple histograms/densities on the same graph.  The number of histograms/densities will be a dynamic number so I cannot hard code.  I was hoping that the histogram/density statements took a "group" option similar to the series/scatter statements in sgplot, but that's a big negative.  &lt;BR /&gt;
&lt;BR /&gt;
Any simple solutions?&lt;BR /&gt;
&lt;BR /&gt;
thanks</description>
      <pubDate>Thu, 29 Apr 2010 14:05:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12549#M228</guid>
      <dc:creator>GDA</dc:creator>
      <dc:date>2010-04-29T14:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12550#M229</link>
      <description>Are you trying to show multiple histograms separately on the same page or overlay one histogram atop the other? I assume the first.&lt;BR /&gt;
&lt;BR /&gt;
In the past I created GREPLAY templates that would accommodate various numbers of histograms on the same page. The advantage is that when you run the graphs through the treplay template you do not have to assign all the panels.&lt;BR /&gt;
&lt;BR /&gt;
Today, in 9.2 phase 2 I would create various templates using %sgdesign and then use macro language to determine the number of histograms and thus the appropriate template to use. &lt;BR /&gt;
&lt;BR /&gt;
The issue is the min and max number of histograms that you want to display.</description>
      <pubDate>Thu, 29 Apr 2010 19:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12550#M229</guid>
      <dc:creator>barheat</dc:creator>
      <dc:date>2010-04-29T19:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12551#M230</link>
      <description>The easiest way to do this would be to use PROC SGPANEL. Put your "group" variable on the PANELBY statement and define your histogram as you would for SGPLOT. The procedure will create a histogram in a cell per group value. The procedure will also paginate to prevent the cells from getting too small, but you can override that behavior by specifying the ONEPANEL option on the PANELBY statement. Let me know if this is what you want.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
Dan</description>
      <pubDate>Thu, 29 Apr 2010 19:46:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12551#M230</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2010-04-29T19:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12552#M231</link>
      <description>Actually I am trying to overlay them on top of each other.  I've used the sgpanel with the group and onepanel options and it's "ok" but not quite what I'm looking for.  I'd really have all plots overlaid instead of individually created and in a matrix type of output.&lt;BR /&gt;
&lt;BR /&gt;
If there's no simple way to do this I'll make it work.  Just thought I'd check.</description>
      <pubDate>Thu, 29 Apr 2010 22:09:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12552#M231</guid>
      <dc:creator>GDA</dc:creator>
      <dc:date>2010-04-29T22:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12553#M232</link>
      <description>The following code is one way you can do it:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
%macro OverlayHist(ds); &lt;BR /&gt;
proc contents data=&amp;amp;ds out=vars; run;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
set vars end=_last_;&lt;BR /&gt;
if (type = 1) then CALL SYMPUTX(CATS("varname",_N_),name);&lt;BR /&gt;
if (_last_) then CALL SYMPUTX("dimvars",_N_);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sgplot data=&amp;amp;ds;&lt;BR /&gt;
%do i=1 %to &amp;amp;dimvars;&lt;BR /&gt;
  histogram &amp;amp;&amp;amp;varname&amp;amp;i / transparency=0.5;&lt;BR /&gt;
%end;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/* Generate the output */&lt;BR /&gt;
data class;&lt;BR /&gt;
set sashelp.class (keep=weight height);&lt;BR /&gt;
run;&lt;BR /&gt;
%OverlayHist(class);&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 30 Apr 2010 03:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12553#M232</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2010-04-30T03:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12554#M233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;this is very easy on R, I am frustrated I can't just do it in SAS - I woudl expect paid software could do it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;many histograms of the same variable by groups or class variables in the sas terminology - all in the same chart not below each other - sometimes you want below, sometimes not&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2013 23:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12554#M233</guid>
      <dc:creator>mariosegal</dc:creator>
      <dc:date>2013-02-20T23:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12555#M234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not certain of the form of your data. Do you have multiple variables X1, X2, X3,.... or do you have one variable and a classification variable that define subpopulations (X, and Category)?&amp;nbsp; Example data would be helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've written a few blog posts on this topic:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;For overlaying histograms of two variables, see&lt;A href="http://blogs.sas.com/content/iml/2011/06/21/overlaying-two-histograms-in-sas/" title="http://blogs.sas.com/content/iml/2011/06/21/overlaying-two-histograms-in-sas/"&gt;&amp;nbsp; Overlaying two histograms in SAS - The DO Loop&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;For overlaying densities, see &lt;A class="active_link" href="http://blogs.sas.com/content/iml/2012/01/13/overlay-density-estimates-on-a-plot/" title="http://blogs.sas.com/content/iml/2012/01/13/overlay-density-estimates-on-a-plot/"&gt; Overlay density estimates on a plot - The DO Loop&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;If you have a classification variable that defines the groups, here's how you can change the data structure so that each category has it's own variable: &lt;A href="http://blogs.sas.com/content/iml/2011/11/04/reshape-data-so-that-each-category-becomes-a-new-variable/" title="http://blogs.sas.com/content/iml/2011/11/04/reshape-data-so-that-each-category-becomes-a-new-variable/"&gt; Reshape data so that each category becomes a new variable - The DO Loop&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 13:26:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12555#M234</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-02-21T13:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12556#M235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My data is very simple, one row per person, each row has multiple columns among them one variable that defines the class it is a numeric value with a format, in addition there is another variable with the vaiable I want the histogram or density for say it is ATM withdrawals. I have seen your posts and I am sure they work, I am commenting as a SAS user who also uses R that it is unnecessarilly difficult in SAS to have to call template to do it when in R you just call the graph fnction and get it done - my point is that sgplot orsganel should be able to do it with some defined option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What SAS does with my comment is really up to them, the can ignore and find one day we are all using R, or they can improve the procedures and maintain supremacy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why should I write complicated code when ic an choose simpe code&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 14:02:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12556#M235</guid>
      <dc:creator>mariosegal</dc:creator>
      <dc:date>2013-02-21T14:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12557#M236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Probably the easiest way to do it is to use a Proc Gplot 'needle' plot ... this makes it very-very easy to overlay the plots, and if you've got SAS 9.3 then you can even take advantage of alpha-transparent colors so that the overlapping bars get the combined-color effect (eg, yellow+blue=green).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a simple example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data foo; set sashelp.stocks&lt;/P&gt;&lt;P&gt;(where=(date&amp;gt;='01jan1990'd and date&amp;lt;'01jan1996'd and stock in ('IBM' 'Intel')));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;axis1 label=none order=('01jan1990'd to '01jan1996'd by year);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;symbol1 value=none interpol=needle width=4 color=AFFE60077;&lt;/P&gt;&lt;P&gt;symbol2 value=none interpol=needle width=4 color=A42C0FB77;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;title "Gplot 'needle' plots (with overlapping transparent colors)";&lt;/P&gt;&lt;P&gt;proc gplot data=foo;&lt;/P&gt;&lt;P&gt;plot close*date=stock / haxis=axis1 vzero;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="needle_plot.png" class="jive-image-thumbnail jive-image" height="499" src="https://communities.sas.com/legacyfs/online/3115_needle_plot.png" style="width: 664px; height: 498.73777777777775px;" width="664" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 14:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12557#M236</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2013-02-21T14:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12558#M237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or if you've got separate variables, you can use the other gplot syntax (instead of plot y*x=z) ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;plot y1*x y2*x / overlay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 14:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12558#M237</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2013-02-21T14:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12559#M238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I understand your concern.&amp;nbsp; I made the same points when I first encountered this situation in late 2011, and I passed on my comments and suggestions to the SAS graphics group.&amp;nbsp; I am sure that they are aware of these concerns.&amp;nbsp; The next release of the ODS SG Procedures is SAS 9.4, which is scheduled for later this year.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 14:14:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12559#M238</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-02-21T14:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12560#M239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As Rick said, there are ways to do this that does not require GTL Template code.&amp;nbsp; SGPLOT can do the overlaid histograms with a few lines of code once your data is in columns and SGPANEL can do the class panel.&amp;nbsp; As we see more interest in creating grouped histograms, we can certainly add the GROUP or CLASS feature to the Histogram statement.&amp;nbsp; In the meantime, here are a couple of links from previous articles. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://blogs.sas.com/content/graphicallyspeaking/2012/03/18/graphs-with-class/" title="http://blogs.sas.com/content/graphicallyspeaking/2012/03/18/graphs-with-class/"&gt;&amp;nbsp; Graphs with class - Graphically Speaking&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://blogs.sas.com/content/graphicallyspeaking/2012/02/06/comparative-densities/" title="http://blogs.sas.com/content/graphicallyspeaking/2012/02/06/comparative-densities/"&gt;&amp;nbsp; Comparative density plots - Graphically Speaking&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 14:29:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12560#M239</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2013-02-21T14:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12561#M240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the help, I am not able to replicate what you did. I am confused as you seem to need 3 dimensions in your chart - the date, the stock and thh close, whereas I only have 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a summary of my data - the relevant columns only, I would like overlayed histograms/densities for each group of the Value - so in the y axis I would see how many HHID had 4 or 5 or 4-6 depending on the histogram bins. Overall I have 6 groups (amnd I may filter some) and values go from zero and there are quite a few of those to maybe 100 or so&lt;/P&gt;&lt;DIV align="center"&gt; &lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV align="center"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;TABLE cellpadding="5" cellspacing="0" class="table" frame="box" rules="all" summary="Procedure Print: Data Set DATA.MAIN_201212"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD colspan="1" style="text-align: center;"&gt;&lt;STRONG&gt;OBS&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD colspan="1" style="text-align: center;"&gt;&lt;STRONG&gt;HHID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD colspan="1" style="text-align: center;"&gt;&lt;STRONG&gt;Group&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD colspan="1" style="text-align: center;"&gt;&lt;STRONG&gt;Value&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;229&lt;/TH&gt;&lt;TD class="l data"&gt;200007518&lt;/TD&gt;&lt;TD class="r data"&gt;Sheetz Only &lt;/TD&gt;&lt;TD class="r data"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;415&lt;/TH&gt;&lt;TD class="l data"&gt;200010892&lt;/TD&gt;&lt;TD class="r data"&gt;Sheetz Only &lt;/TD&gt;&lt;TD class="r data"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;755&lt;/TH&gt;&lt;TD class="l data"&gt;200027228&lt;/TD&gt;&lt;TD class="r data"&gt;Sheetz and Any Other &lt;/TD&gt;&lt;TD class="r data"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;1071&lt;/TH&gt;&lt;TD class="l data"&gt;200042500&lt;/TD&gt;&lt;TD class="r data"&gt;Sheetz and Any Other &lt;/TD&gt;&lt;TD class="r data"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;1089&lt;/TH&gt;&lt;TD class="l data"&gt;200042790&lt;/TD&gt;&lt;TD class="r data"&gt;Sheetz and Any Other &lt;/TD&gt;&lt;TD class="r data"&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;1177&lt;/TH&gt;&lt;TD class="l data"&gt;200044180&lt;/TD&gt;&lt;TD class="r data"&gt;Sheetz and Any Other &lt;/TD&gt;&lt;TD class="r data"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;1244&lt;/TH&gt;&lt;TD class="l data"&gt;200045652&lt;/TD&gt;&lt;TD class="r data"&gt;Sheetz and Any Other &lt;/TD&gt;&lt;TD class="r data"&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;1955&lt;/TH&gt;&lt;TD class="l data"&gt;200052426&lt;/TD&gt;&lt;TD class="r data"&gt;Sheetz and Any Other &lt;/TD&gt;&lt;TD class="r data"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;2019&lt;/TH&gt;&lt;TD class="l data"&gt;200052940&lt;/TD&gt;&lt;TD class="r data"&gt;Sheetz and Any Other &lt;/TD&gt;&lt;TD class="r data"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;2159&lt;/TH&gt;&lt;TD class="l data"&gt;200054454&lt;/TD&gt;&lt;TD class="r data"&gt;Sheetz and Any Other &lt;/TD&gt;&lt;TD class="r data"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am starting to see how the plot procedure works, but I maintain it is more complex than needed and so people do not use its full power, which is a shame&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 14:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12561#M240</guid>
      <dc:creator>mariosegal</dc:creator>
      <dc:date>2013-02-21T14:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12562#M241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you post up a copy of your R graph (or if you don't have an R graph, maybe one drawn by hand)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 14:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12562#M241</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2013-02-21T14:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12563#M242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As Sanjay says, if you have individual variables, this is straightforward with SGPLOT.&amp;nbsp; The complexities of my blogs posts were because I wanted to support a class (grouping) variable. Apparently the OP is in the same situation, which means that currently he needs to use some DATA step or SQL code to &lt;A href="http://blogs.sas.com/content/iml/2011/11/04/reshape-data-so-that-each-category-becomes-a-new-variable/" title="http://blogs.sas.com/content/iml/2011/11/04/reshape-data-so-that-each-category-becomes-a-new-variable/"&gt;&amp;nbsp; Reshape data so that each category becomes a new variable - The DO Loop&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@GDA My recommendation is to convert your data from the "long" to the "wide" format as I describe in my "Reshape data" post, and then use Dan's %OverlayHist macro to replicate the HISTOGRAM statement in PROC SGPLOT as many times as you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are those who would say that overlaying histograms does not work very well beyond 2-3 variables and that we should consider whether&amp;nbsp; "comparative histograms" would visualize the data better, I say that I agree...usually. However, in certain special situations I've wanted to overlay dozens of histrograms. See &lt;A href="http://blogs.sas.com/content/iml/2012/05/16/the-curious-case-of-random-eigenvalues/" title="http://blogs.sas.com/content/iml/2012/05/16/the-curious-case-of-random-eigenvalues/"&gt;Eigenvalues of a random symmetric matrix: A simulation approach&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 14:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12563#M242</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-02-21T14:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12564#M243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My pleasure, attached 4 samples from R, 3 versions that could work, I also added a faceted one which was not what I asked for&amp;nbsp; and that&amp;nbsp; I CAN do in sgpanel &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the code I used is below, I also had to read the data and create a factor, which is not dissimilar to having a sas format - all in one line with minimal options, will get a bit more complicated if I wanted to format axes or add axis labels (in either platform)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; #chart1&lt;/P&gt;&lt;P&gt;ggplot(small, aes(x=sheetz_num,fill=atm_group)) + geom_histogram(alpha=.2, position="identity",binwidth=1)+labs(title="Chart1")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#chart2&lt;/P&gt;&lt;P&gt;ggplot(small, aes(x=sheetz_num,fill=atm_group)) + geom_histogram(alpha=1, position="dodge",binwidth=1)+labs(title="Chart2")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#chart3&lt;/P&gt;&lt;P&gt;ggplot(small, aes(x=sheetz_num,color=atm_group)) + geom_density()+labs(title="Chart3")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#chart4&lt;/P&gt;&lt;P&gt;ggplot(small, aes(x=sheetz_num)) + geom_histogram(alpha=.2, position="identity",binwidth=1)+labs(title="Chart4")+facet_grid(atm_group~.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not believe this is possible with gplot as suggested, unless I transform the data first with Proc freq (basically creating the bins) so I can have 3 variables as in the stock example, but why should I do that, for that matter I can maybe have 2 powerpoint charts on top of each other somehow, it would be cumbersome and time consuming. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I appreciate the help, and I do it because I like SAS and would like to be able to do it in SAS,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 15:39:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12564#M243</guid>
      <dc:creator>mariosegal</dc:creator>
      <dc:date>2013-02-21T15:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12565#M244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the examples!&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's some code showing how you could create something like Chart1 using gplot.&lt;/P&gt;&lt;P&gt;Yes, you'll have to pre-summarize your data.&lt;/P&gt;&lt;P&gt;One suggestion - once you get a plot you like, you might want to write a macro so that you can generate the plot by passing parameters to the macro (similar to what you're doing in R) rather than repeating the code each time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data foo;&lt;/P&gt;&lt;P&gt;input atm_group sheetz_num count;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 1 1950&lt;/P&gt;&lt;P&gt;1 2 1500&lt;/P&gt;&lt;P&gt;1 3 900&lt;/P&gt;&lt;P&gt;1 4 400&lt;/P&gt;&lt;P&gt;1 5 300&lt;/P&gt;&lt;P&gt;2 1 6100&lt;/P&gt;&lt;P&gt;2 2 2400&lt;/P&gt;&lt;P&gt;2 3 1600&lt;/P&gt;&lt;P&gt;2 4 1000&lt;/P&gt;&lt;P&gt;2 5 550&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;axis1 label=(angle=90 'count') minor=none offset=(0,0);&lt;/P&gt;&lt;P&gt;axis2 order=(0 to 20 by 5) minor=none offset=(0,0);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;symbol1 value=none interpol=needle width=15 color=Af0582f55;&lt;/P&gt;&lt;P&gt;symbol2 value=none interpol=needle width=15 color=A39dee455;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;legend1 position=(right middle) across=1 label=(position=top);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;title "Chart1";&lt;/P&gt;&lt;P&gt;proc gplot data=foo;&lt;/P&gt;&lt;P&gt;plot count*sheetz_num=atm_group / &lt;/P&gt;&lt;P&gt; vzero vaxis=axis1 haxis=axis2 legend=legend1&lt;/P&gt;&lt;P&gt; autohref autovref chref=grayee cvref=grayee;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="sheetz.png" class="jive-image-thumbnail jive-image" height="507" src="https://communities.sas.com/legacyfs/online/3118_sheetz.png" style="width: 675px; height: 507px;" width="675" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 16:00:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12565#M244</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2013-02-21T16:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12566#M245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had the same problem as your Chart 3 last year.&amp;nbsp; One solution (to chart 3) is to create your own template file.&amp;nbsp; It's kind of like a layout() in R.&amp;nbsp;&amp;nbsp; This one will create 3 densities overlaid on one plot.&amp;nbsp; I can give you a full example if you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc template;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; define statgraph d;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; begingraph;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; layout overlay / xaxisopts=(label='Volume');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; densityplot eval((log(src = 'bc') + 1) * vol) /&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; kernel() lineattrs=(color=purple);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; densityplot eval((log(src = 'bp') + 1) * vol) /&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; kernel() lineattrs=(color=red);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; densityplot eval((log(src = 'fp') + 1) * vol) /&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; kernel() lineattrs=(color=gray);&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp; endlayout;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; endgraph;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sgrender data=abcd template=d&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 16:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12566#M245</guid>
      <dc:creator>blchri</dc:creator>
      <dc:date>2013-02-21T16:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12567#M246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all - it is clear exactly how to do it in SAS now&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I want to emphasize is that in R I am not doing any pre-processing, nor am I required to create a template or a macro, I am just using ggplot2 - the equivalent in SAS would be to do it in sgplot/sgpanel/gplot without pre-processing. The simple calls I showed &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;do all the work&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I worked at SAS, implementing the grammar of graphics and allowing this sort of things would be on my priority list&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I really like SAS, I believe it can do most of what people need, and every day I discover new things (The ability to call support for help is a super valid feature, the R forums are not quite the same). And it deals with large datasets easily while in R we are constrained to in memory or have to use special techniques - but graphics is one area where it lags a bit - as shown here - it is hard to always have labels on top of bars as well, if they do not fit perfectly they just are not printed. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 16:18:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12567#M246</guid>
      <dc:creator>mariosegal</dc:creator>
      <dc:date>2013-02-21T16:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Histograms/Densities on same graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12568#M247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you feel that R graphics are better for your needs, you can actually call R from SAS using IML studio.&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Here's some information about calling R from SAS:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/rnd/app/studio/statr.pdf" title="http://support.sas.com/rnd/app/studio/statr.pdf"&gt;http://support.sas.com/rnd/app/studio/statr.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 16:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Multiple-Histograms-Densities-on-same-graph/m-p/12568#M247</guid>
      <dc:creator>blchri</dc:creator>
      <dc:date>2013-02-21T16:37:30Z</dc:date>
    </item>
  </channel>
</rss>

