<?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: Density plot with group option in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Density-plot-with-group-option/m-p/652120#M195744</link>
    <description>&lt;P&gt;I am not sure I understand the request. But please look at this example and scroll down to the second example, is that what you want? &lt;A href="https://documentation.sas.com/?docsetId=grstatproc&amp;amp;docsetTarget=p0o7d7xxvzs9qmn1vctlufpz1448.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1mf6h1p523enin13tjqsi5y9xf1" target="_blank"&gt;https://documentation.sas.com/?docsetId=grstatproc&amp;amp;docsetTarget=p0o7d7xxvzs9qmn1vctlufpz1448.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1mf6h1p523enin13tjqsi5y9xf1&lt;/A&gt;&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Sun, 31 May 2020 22:13:29 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-05-31T22:13:29Z</dc:date>
    <item>
      <title>Density plot with group option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Density-plot-with-group-option/m-p/652119#M195743</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have been having troubles with density plots in sgplot/sgpanel.&amp;nbsp;My dataset has 4&amp;nbsp;subgroups and, when&amp;nbsp;I use the density statement with the group option,&amp;nbsp;a&amp;nbsp;density within each group is computed without taking in consideration the proportion of each subgroup&amp;nbsp;with the&amp;nbsp;whole dataset.&amp;nbsp;How can I "resize" these curves, so that each density reflects its actual size with respect to the whole dataset?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 31 May 2020 22:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Density-plot-with-group-option/m-p/652119#M195743</guid>
      <dc:creator>marghe</dc:creator>
      <dc:date>2020-05-31T22:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Density plot with group option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Density-plot-with-group-option/m-p/652120#M195744</link>
      <description>&lt;P&gt;I am not sure I understand the request. But please look at this example and scroll down to the second example, is that what you want? &lt;A href="https://documentation.sas.com/?docsetId=grstatproc&amp;amp;docsetTarget=p0o7d7xxvzs9qmn1vctlufpz1448.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1mf6h1p523enin13tjqsi5y9xf1" target="_blank"&gt;https://documentation.sas.com/?docsetId=grstatproc&amp;amp;docsetTarget=p0o7d7xxvzs9qmn1vctlufpz1448.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1mf6h1p523enin13tjqsi5y9xf1&lt;/A&gt;&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 31 May 2020 22:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Density-plot-with-group-option/m-p/652120#M195744</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-31T22:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Density plot with group option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Density-plot-with-group-option/m-p/652122#M195745</link>
      <description>Thanks for your reply but unfortunately I couldn’t find what I was looking for. I’ll make an example to better explain :&lt;BR /&gt;I need to analyse the distribution of a continuous variable (let’s call it X) according to these 4 subgroups:&lt;BR /&gt;&lt;BR /&gt;TRT GENDER #SUBJECTS&lt;BR /&gt;A M 20&lt;BR /&gt;A F 30&lt;BR /&gt;B M 10&lt;BR /&gt;B F 40&lt;BR /&gt;____&lt;BR /&gt;100&lt;BR /&gt;If we take the first subgroup “A - M”, for example, the density of X will be computed on a total of 20 subjects instead of 100. As a result from the procedure, we will get 4 density functions conditional to each subgroup; while I would like to have a joint density function on (X,TRT,GENDER) - made up 4 densities. It’s really up to the total used to do computations.&lt;BR /&gt;Hope this example gives you some more insight on my question.&lt;BR /&gt;Thank you!</description>
      <pubDate>Sun, 31 May 2020 22:41:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Density-plot-with-group-option/m-p/652122#M195745</guid>
      <dc:creator>marghe</dc:creator>
      <dc:date>2020-05-31T22:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Density plot with group option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Density-plot-with-group-option/m-p/652123#M195746</link>
      <description>&lt;P&gt;Well, probably I still don't understand. Can you explain why the example I mentioned is NOT what you want?&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 31 May 2020 22:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Density-plot-with-group-option/m-p/652123#M195746</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-31T22:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Density plot with group option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Density-plot-with-group-option/m-p/652128#M195750</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/199678"&gt;@marghe&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have been having troubles with density plots in sgplot/sgpanel.&amp;nbsp;My dataset has 4&amp;nbsp;subgroups and, when&amp;nbsp;I use the density statement with the group option,&amp;nbsp;a&amp;nbsp;density within each group is computed without taking in consideration the proportion of each subgroup&amp;nbsp;with the&amp;nbsp;whole dataset.&amp;nbsp;How can I "resize" these curves, so that each density reflects its actual size with respect to the whole dataset?&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please at least show the code you have attempted. Without that we have no clue what options you may already be using (or not using) that might be part of a solution. Post the code in a code box opened with the forum's &amp;lt;/&amp;gt; or "running man" icon to preserve formatting. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And it would help a lot to have a set of data to display.&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Only include the variables needed to make the plot.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jun 2020 00:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Density-plot-with-group-option/m-p/652128#M195750</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-01T00:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Density plot with group option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Density-plot-with-group-option/m-p/652188#M195779</link>
      <description>&lt;P&gt;Thanks for your replies, here is&amp;nbsp;my code (it's easier for me to use a sashelp dataset):&lt;/P&gt;&lt;PRE&gt;data dataset;
set sashelp.class;
run;

/*Age categorization*/
data class;
set dataset;
if Age&amp;lt;=13 then Age_cat='&amp;lt;=13';
else Age_cat='&amp;gt;13';
run;

/*Sex and Age category combined to get a group with 4 levels*/
data class_group;
set class;
if Sex='M' then do;
if Age_cat='&amp;lt;=13' then cat='M - &amp;lt;=13';
else cat='M - &amp;gt;13';
end;
else do;
if Age_cat='&amp;lt;=13' then cat='F - &amp;lt;=13';
else cat='F - &amp;gt;13';
end;
run;

proc sort data=class_group;
by cat;
run;

/*Density plot by group (Plot1)*/
title 'Height of boys and girls according to age category';
proc sgplot data=class_group;
density height /group=cat type=kernel;
xaxis label='HEIGHT';
run;

/*From class_group, 5 subjects have cat='F - &amp;lt;=13' and the total dataset has 19 subjects*/
/*In a histogram, frequencies are computed within each subgroup (Plot 2)*/
title 'Height of boys and girls according to age category';
proc sgplot data=class_group(where=(cat='F - &amp;lt;=13'));
histogram height /group=cat binwidth=10;
xaxis label='HEIGHT' values=(50 to 70 by 10);
run;&lt;/PRE&gt;&lt;P&gt;Plot1&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Plot1.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/40204i92B1523077A315E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Plot1.PNG" alt="Plot1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Plot 2&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Plot2.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/40205i4F9F0B3547134056/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Plot2.PNG" alt="Plot2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The red lines indicate the bars' heights if frequency of 'F - &amp;lt;=13'&amp;nbsp;was computed on the total dataset (19 subjects) instead of the size of the subgroup (5 subjects).&lt;/P&gt;&lt;P&gt;I would like that in the computation of densities for each group these 19 subjects were used, not only those belonging to that particular subgroup. Do I have to use weights?&lt;/P&gt;&lt;P&gt;Hope this clarifies a bit my question, thanks you all!!&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jun 2020 10:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Density-plot-with-group-option/m-p/652188#M195779</guid>
      <dc:creator>marghe</dc:creator>
      <dc:date>2020-06-01T10:25:11Z</dc:date>
    </item>
  </channel>
</rss>

