<?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 How to replace the missing values with the mean of the variable in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/How-to-replace-the-missing-values-with-the-mean-of-the-variable/m-p/400149#M3559</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a data set with several variables (X1, X2, X3,….) and I am trying to replace the missing values in the data set with the mean of the variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my sample code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA Complete_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set mydata.original_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If X1= . Then X1 = mean(X1);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, it’s not working. Please advise.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Sun, 01 Oct 2017 18:21:26 GMT</pubDate>
    <dc:creator>murad130</dc:creator>
    <dc:date>2017-10-01T18:21:26Z</dc:date>
    <item>
      <title>How to replace the missing values with the mean of the variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-replace-the-missing-values-with-the-mean-of-the-variable/m-p/400149#M3559</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a data set with several variables (X1, X2, X3,….) and I am trying to replace the missing values in the data set with the mean of the variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my sample code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA Complete_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set mydata.original_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If X1= . Then X1 = mean(X1);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, it’s not working. Please advise.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Oct 2017 18:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-replace-the-missing-values-with-the-mean-of-the-variable/m-p/400149#M3559</guid>
      <dc:creator>murad130</dc:creator>
      <dc:date>2017-10-01T18:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the missing values with the mean of the variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-replace-the-missing-values-with-the-mean-of-the-variable/m-p/400153#M3560</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc stdize data=&lt;SPAN&gt;mydata.original_data&lt;/SPAN&gt; reponly method=mean out=&lt;SPAN&gt;Complete_data&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P&gt;var X1 X2 X3;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Oct 2017 18:47:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-replace-the-missing-values-with-the-mean-of-the-variable/m-p/400153#M3560</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2017-10-01T18:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the missing values with the mean of the variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-replace-the-missing-values-with-the-mean-of-the-variable/m-p/400162#M3561</link>
      <description>&lt;P&gt;The MEAN function in SAS works only on a row of data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the mean of a single variable is the same value, in this case missing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you wanted a data step approach you would need two passes, one to calculate the average and a second to merge it in with the data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC STDIZE is easier to work with IMO.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Oct 2017 21:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-replace-the-missing-values-with-the-mean-of-the-variable/m-p/400162#M3561</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-01T21:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the missing values with the mean of the variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-replace-the-missing-values-with-the-mean-of-the-variable/m-p/400186#M3563</link>
      <description>&lt;P&gt;It worked!&lt;/P&gt;&lt;P&gt;Thank you so much for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 05:04:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-replace-the-missing-values-with-the-mean-of-the-variable/m-p/400186#M3563</guid>
      <dc:creator>murad130</dc:creator>
      <dc:date>2017-10-02T05:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the missing values with the mean of the variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-replace-the-missing-values-with-the-mean-of-the-variable/m-p/400187#M3564</link>
      <description>&lt;P&gt;Thank you very much for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 05:06:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-replace-the-missing-values-with-the-mean-of-the-variable/m-p/400187#M3564</guid>
      <dc:creator>murad130</dc:creator>
      <dc:date>2017-10-02T05:06:44Z</dc:date>
    </item>
  </channel>
</rss>

