<?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: Did I do this right? Merging and Proc Means in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Did-I-do-this-right-Merging-and-Proc-Means/m-p/601390#M173941</link>
    <description>&lt;P&gt;You do seem to have the class and var reversed.&lt;/P&gt;
&lt;P&gt;CLASS is for breaking your data into groups.&lt;/P&gt;
&lt;P&gt;VAR is the numeric variable you want to analyze.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks like you want to analyze WEIGHT and check it in the different classes defined by the values of smoking and marriage.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Nov 2019 14:50:34 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-11-04T14:50:34Z</dc:date>
    <item>
      <title>Did I do this right? Merging and Proc Means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Did-I-do-this-right-Merging-and-Proc-Means/m-p/601372#M173936</link>
      <description>&lt;P&gt;Here is the problem:&lt;/P&gt;&lt;P&gt;Using the SAS data set SASHELP.BWEIGHT, write all the SAS code necessary to calculate the average of baby's weight for each group defined by level of smoking status by marital status. Then calculate the difference between the individual baby's weight and the average weight for the babies in the group defined by mother's smoking status and marital status.&amp;nbsp; Exclude observations with missing data on the relevant variables from the calculations.&amp;nbsp; To solve this problem you will need to &lt;U&gt;use Proc Means&lt;/U&gt; to find the average weight for babies in each condition and then do a merge so the values are available to find the difference for individual babies.&amp;nbsp; Hint – Be sure to consider what to do with the _TYPE_ variable.&lt;/P&gt;&lt;P&gt;Here is what I have:&lt;/P&gt;&lt;P&gt;proc means data=sashelp.bweight Nway ;&lt;BR /&gt;var MomSmoke Married ;&lt;BR /&gt;class Weight ;&lt;BR /&gt;output out= Avg_Weight_Mean&lt;BR /&gt;Mean (MomSmoke Married) = mean_smk mean_mar;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=Avg_Weight_Mean out=new_stat_undup;&lt;BR /&gt;by Weight;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=sashelp.bweight out=bweight2;&lt;BR /&gt;by Weight;&lt;BR /&gt;run;&lt;BR /&gt;data bweight3;&lt;BR /&gt;merge new_stat_undup (in=a) bweight2 (in=b);&lt;BR /&gt;by Weight;&lt;BR /&gt;if a;&lt;BR /&gt;Smoke_diff = Momsmoke - mean_smk;&lt;BR /&gt;Married_diff = Married - mean_mar;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc means data=bweight3 mean stddev;&lt;BR /&gt;class Weight;&lt;BR /&gt;var Smoke_diff Married_diff;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output looks weird and long and I just realized that I get confused with the class and var. Just wondering if someone could double check this for me?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2019 14:13:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Did-I-do-this-right-Merging-and-Proc-Means/m-p/601372#M173936</guid>
      <dc:creator>K_Wils15</dc:creator>
      <dc:date>2019-11-04T14:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: Did I do this right? Merging and Proc Means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Did-I-do-this-right-Merging-and-Proc-Means/m-p/601376#M173937</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/295349"&gt;@K_Wils15&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output looks weird and long and I just realized that I get confused with the class and var. Just wondering if someone could double check this for me?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show us the output, and explain in words what is "weird" and doesn't seem correct.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;To show us the output, paste the output as text into the window that appears when you click on the {i} button; or show us a screen capture of the output.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2019 14:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Did-I-do-this-right-Merging-and-Proc-Means/m-p/601376#M173937</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-04T14:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Did I do this right? Merging and Proc Means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Did-I-do-this-right-Merging-and-Proc-Means/m-p/601385#M173939</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="75492510_2412050352244948_6615440780595036160_n.png" style="width: 557px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33622i93BE9707A2E05CF1/image-size/large?v=v2&amp;amp;px=999" role="button" title="75492510_2412050352244948_6615440780595036160_n.png" alt="75492510_2412050352244948_6615440780595036160_n.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2019 14:42:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Did-I-do-this-right-Merging-and-Proc-Means/m-p/601385#M173939</guid>
      <dc:creator>K_Wils15</dc:creator>
      <dc:date>2019-11-04T14:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: Did I do this right? Merging and Proc Means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Did-I-do-this-right-Merging-and-Proc-Means/m-p/601388#M173940</link>
      <description>I posted a pic down below of a part of the output. It looks wrong because there are missing values in Std DEV and I am not sure if the code even calculated the difference of the birthweights.</description>
      <pubDate>Mon, 04 Nov 2019 14:45:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Did-I-do-this-right-Merging-and-Proc-Means/m-p/601388#M173940</guid>
      <dc:creator>K_Wils15</dc:creator>
      <dc:date>2019-11-04T14:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Did I do this right? Merging and Proc Means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Did-I-do-this-right-Merging-and-Proc-Means/m-p/601390#M173941</link>
      <description>&lt;P&gt;You do seem to have the class and var reversed.&lt;/P&gt;
&lt;P&gt;CLASS is for breaking your data into groups.&lt;/P&gt;
&lt;P&gt;VAR is the numeric variable you want to analyze.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks like you want to analyze WEIGHT and check it in the different classes defined by the values of smoking and marriage.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2019 14:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Did-I-do-this-right-Merging-and-Proc-Means/m-p/601390#M173941</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-04T14:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Did I do this right? Merging and Proc Means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Did-I-do-this-right-Merging-and-Proc-Means/m-p/601397#M173945</link>
      <description>Thanks!</description>
      <pubDate>Mon, 04 Nov 2019 15:05:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Did-I-do-this-right-Merging-and-Proc-Means/m-p/601397#M173945</guid>
      <dc:creator>K_Wils15</dc:creator>
      <dc:date>2019-11-04T15:05:40Z</dc:date>
    </item>
  </channel>
</rss>

