<?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: replace missing value with mean in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118831#M24481</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Works well with this dataset:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;input thing;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;100&lt;/P&gt;&lt;P&gt;101&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;103&lt;/P&gt;&lt;P&gt;104&lt;/P&gt;&lt;P&gt;105&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Can you give the log or the dataset you tried to use it with?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Aug 2013 07:30:47 GMT</pubDate>
    <dc:creator>Murray_Court</dc:creator>
    <dc:date>2013-08-22T07:30:47Z</dc:date>
    <item>
      <title>replace missing value with mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118829#M24479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I need to replace all missing values in a dataset with respective mean.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Find the sample i wrote.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro replace_missing(dataset); &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc means data=&amp;amp;dataset mean ; ; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output out=t (drop=_type_ _freq_) mean=/autoname; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc transpose data=t out=tr; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run; &lt;/P&gt;&lt;P&gt;data _null_; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set Tr end=last ; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput('mean'||left(_n_),col1); &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last then call symput('maxi', _n_); &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* x=left(_N_) */; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* put _N_ maxi last x ; */; &lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;data &amp;amp;dataset; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &amp;amp;dataset; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array num(*) _numeric_; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do n=1 %to &amp;amp;maxi; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if num(&amp;amp;n)=. then num(&amp;amp;n)= &amp;amp;&amp;amp;mean&amp;amp;n; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end; &lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;%mend; &lt;/P&gt;&lt;P&gt;%replace_missing(drop_missing); &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;But this is not working..&lt;/P&gt;&lt;P&gt;Please help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 06:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118829#M24479</guid>
      <dc:creator>supersonic</dc:creator>
      <dc:date>2013-08-22T06:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: replace missing value with mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118830#M24480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;supersonic&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc STANDARD will do this for you, see code sample below.&lt;/P&gt;&lt;DIV style="font-family: Consolas; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; someTest;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;infile&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;dlm&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;","&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; v1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; v2&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;1,100&lt;BR /&gt;2,.&lt;BR /&gt;3,3&lt;BR /&gt;4,.&lt;BR /&gt;.,20&lt;BR /&gt;&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;standard&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=someTest &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=sometest2 &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;replace&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;print&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;print&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=someTest;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;print&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=someTest2;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;means&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=someTest2;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;var&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; v:;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 07:27:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118830#M24480</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2013-08-22T07:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: replace missing value with mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118831#M24481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Works well with this dataset:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;input thing;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;100&lt;/P&gt;&lt;P&gt;101&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;103&lt;/P&gt;&lt;P&gt;104&lt;/P&gt;&lt;P&gt;105&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Can you give the log or the dataset you tried to use it with?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 07:30:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118831#M24481</guid>
      <dc:creator>Murray_Court</dc:creator>
      <dc:date>2013-08-22T07:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: replace missing value with mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118832#M24482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Murray&lt;/P&gt;&lt;P&gt; Its a very huge dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My aim is to replace all the missing values with the corresponding mean value&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 07:45:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118832#M24482</guid>
      <dc:creator>supersonic</dc:creator>
      <dc:date>2013-08-22T07:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: replace missing value with mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118833#M24483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As stated by &lt;A _jive_internal="true" href="https://communities.sas.com/people/Murray_Court"&gt;https://communities.sas.com/people/Murray_Court&lt;/A&gt;, attach a log or describe in more detail what it is that does not work...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 09:23:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118833#M24483</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-08-22T09:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: replace missing value with mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118834#M24484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/64787/HTML/default/viewer.htm#p0rmqauo93yk0kn17r0vp04odrfp.htm" title="http://support.sas.com/documentation/cdl/en/proc/64787/HTML/default/viewer.htm#p0rmqauo93yk0kn17r0vp04odrfp.htm"&gt;Base SAS(R) 9.4 Procedures Guide&lt;/A&gt; (PROC standard replacing missing by mean) == Bruno-s&amp;nbsp; ==&lt;/P&gt;&lt;P&gt;The advantage of this procedure is it is part of SAS/Base Procs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it should be more advanced like being in the Eminer processing, That one is using&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/statug/66103/HTML/default/viewer.htm#statug_mi_toc.htm" title="http://support.sas.com/documentation/cdl/en/statug/66103/HTML/default/viewer.htm#statug_mi_toc.htm"&gt;SAS/STAT(R) 12.3 User's Guide&lt;/A&gt; (Proc MI) .&lt;/P&gt;&lt;P&gt;You nee to be licnesed for that.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 16:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118834#M24484</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2013-08-22T16:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: replace missing value with mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118835#M24485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc stdize data=old out=new missing=mean reponly;&lt;BR /&gt;&amp;nbsp; var _numeric_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;You can also calculate the median first, then read values from a second data set&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2013 14:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-missing-value-with-mean/m-p/118835#M24485</guid>
      <dc:creator>sandyming</dc:creator>
      <dc:date>2013-08-23T14:35:51Z</dc:date>
    </item>
  </channel>
</rss>

