<?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 fill missing value less of variables with the number of missing value less than 3. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-fill-missing-value-less-of-variables-with-the-number-of/m-p/563964#M74989</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really need help in filling the missing value.&lt;/P&gt;&lt;P&gt;I want to fill the missing value of value1, value2 and value3 by ''firm'' with last observation.&lt;/P&gt;&lt;P&gt;But I just want to fill the variable of each firm that with the missing value that less than 5.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;input firm $2. year Month value1 value2 value3;&lt;BR /&gt;cards;&lt;BR /&gt;A 2006 03 7 7 5&lt;BR /&gt;A 2006 03 8 8 .&lt;BR /&gt;A 2006 03 . 9 1&lt;BR /&gt;A 2006 06 5 . .&lt;BR /&gt;A 2006 06 8 7 4&lt;BR /&gt;A 2006 06 . 4 3&lt;BR /&gt;A 2006 09 . . 2&lt;BR /&gt;A 2006 09 9 7 1&lt;BR /&gt;A 2006 09 . . 5&lt;BR /&gt;A 2007 03 . 7 .&lt;BR /&gt;A 2007 03 . 7 8&lt;BR /&gt;A 2007 03 . 7 .&lt;BR /&gt;A 2007 06 . 3 2&lt;BR /&gt;A 2007 06 . 7 6&lt;BR /&gt;A 2007 06 . 8 .&lt;BR /&gt;B 2006 03 . 2 1&lt;BR /&gt;B 2006 03 12 7 .&lt;BR /&gt;B 2006 03 10 . .&lt;BR /&gt;B 2007 03 9 1 2&lt;BR /&gt;B 2007 03 1 . .&lt;BR /&gt;B 2007 03 . 3 4&lt;BR /&gt;B 2007 03 . . .&lt;BR /&gt;B 2007 03 . 3 4&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want:&lt;/P&gt;&lt;P&gt;A 2006 03 7 7 5&lt;BR /&gt;A 2006 03 8 8 &lt;STRONG&gt;5&lt;/STRONG&gt;&lt;BR /&gt;A 2006 03 . 9 1&lt;BR /&gt;A 2006 06 5 &lt;STRONG&gt;9&lt;/STRONG&gt; &lt;STRONG&gt;1&lt;/STRONG&gt;&lt;BR /&gt;A 2006 06 8 7 4&lt;BR /&gt;A 2006 06 . 4 3&lt;BR /&gt;A 2006 09 . &lt;STRONG&gt;4&lt;/STRONG&gt; 2&lt;BR /&gt;A 2006 09 9 7 1&lt;BR /&gt;A 2006 09 . &lt;STRONG&gt;7&lt;/STRONG&gt; 5&lt;BR /&gt;A 2007 03 . 7 &lt;STRONG&gt;5&lt;/STRONG&gt;&lt;BR /&gt;A 2007 03 . 7 8&lt;BR /&gt;A 2007 03 . 7 &lt;STRONG&gt;8&lt;/STRONG&gt;&lt;BR /&gt;A 2007 06 . 3 2&lt;BR /&gt;A 2007 06 . 7 6&lt;BR /&gt;A 2007 06 . 8 &lt;STRONG&gt;6&lt;/STRONG&gt;&lt;BR /&gt;B 2006 03 . 2 1&lt;BR /&gt;B 2006 03 12 7 &lt;STRONG&gt;1&lt;/STRONG&gt;&lt;BR /&gt;B 2006 03 10 &lt;STRONG&gt;7&lt;/STRONG&gt; &lt;STRONG&gt;1&lt;/STRONG&gt;&lt;BR /&gt;B 2007 03 9 1 2&lt;BR /&gt;B 2007 03 1 &lt;STRONG&gt;1&lt;/STRONG&gt; &lt;STRONG&gt;2&lt;/STRONG&gt;&lt;BR /&gt;B 2007 03 &lt;STRONG&gt;1&lt;/STRONG&gt; 3 4&lt;BR /&gt;B 2007 03 &lt;STRONG&gt;1&lt;/STRONG&gt; &lt;STRONG&gt;3&lt;/STRONG&gt; &lt;STRONG&gt;4&lt;/STRONG&gt;&lt;BR /&gt;B 2007 03 &lt;STRONG&gt;1&lt;/STRONG&gt; 3 4&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So there are two requirements when filling the missing value:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Fill the missing value of each variable by 'firm' with previous data.&lt;/P&gt;&lt;P&gt;2. If the number of missing value &amp;gt; 5, then we do not fill that variable. In this case, because the number of the missing value of value1 of firm A &amp;gt; 5, then it will not be filled by the lasted data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much.&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>Thu, 06 Jun 2019 04:47:48 GMT</pubDate>
    <dc:creator>Maomao_Hui</dc:creator>
    <dc:date>2019-06-06T04:47:48Z</dc:date>
    <item>
      <title>How to fill missing value less of variables with the number of missing value less than 3.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-fill-missing-value-less-of-variables-with-the-number-of/m-p/563964#M74989</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really need help in filling the missing value.&lt;/P&gt;&lt;P&gt;I want to fill the missing value of value1, value2 and value3 by ''firm'' with last observation.&lt;/P&gt;&lt;P&gt;But I just want to fill the variable of each firm that with the missing value that less than 5.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;input firm $2. year Month value1 value2 value3;&lt;BR /&gt;cards;&lt;BR /&gt;A 2006 03 7 7 5&lt;BR /&gt;A 2006 03 8 8 .&lt;BR /&gt;A 2006 03 . 9 1&lt;BR /&gt;A 2006 06 5 . .&lt;BR /&gt;A 2006 06 8 7 4&lt;BR /&gt;A 2006 06 . 4 3&lt;BR /&gt;A 2006 09 . . 2&lt;BR /&gt;A 2006 09 9 7 1&lt;BR /&gt;A 2006 09 . . 5&lt;BR /&gt;A 2007 03 . 7 .&lt;BR /&gt;A 2007 03 . 7 8&lt;BR /&gt;A 2007 03 . 7 .&lt;BR /&gt;A 2007 06 . 3 2&lt;BR /&gt;A 2007 06 . 7 6&lt;BR /&gt;A 2007 06 . 8 .&lt;BR /&gt;B 2006 03 . 2 1&lt;BR /&gt;B 2006 03 12 7 .&lt;BR /&gt;B 2006 03 10 . .&lt;BR /&gt;B 2007 03 9 1 2&lt;BR /&gt;B 2007 03 1 . .&lt;BR /&gt;B 2007 03 . 3 4&lt;BR /&gt;B 2007 03 . . .&lt;BR /&gt;B 2007 03 . 3 4&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want:&lt;/P&gt;&lt;P&gt;A 2006 03 7 7 5&lt;BR /&gt;A 2006 03 8 8 &lt;STRONG&gt;5&lt;/STRONG&gt;&lt;BR /&gt;A 2006 03 . 9 1&lt;BR /&gt;A 2006 06 5 &lt;STRONG&gt;9&lt;/STRONG&gt; &lt;STRONG&gt;1&lt;/STRONG&gt;&lt;BR /&gt;A 2006 06 8 7 4&lt;BR /&gt;A 2006 06 . 4 3&lt;BR /&gt;A 2006 09 . &lt;STRONG&gt;4&lt;/STRONG&gt; 2&lt;BR /&gt;A 2006 09 9 7 1&lt;BR /&gt;A 2006 09 . &lt;STRONG&gt;7&lt;/STRONG&gt; 5&lt;BR /&gt;A 2007 03 . 7 &lt;STRONG&gt;5&lt;/STRONG&gt;&lt;BR /&gt;A 2007 03 . 7 8&lt;BR /&gt;A 2007 03 . 7 &lt;STRONG&gt;8&lt;/STRONG&gt;&lt;BR /&gt;A 2007 06 . 3 2&lt;BR /&gt;A 2007 06 . 7 6&lt;BR /&gt;A 2007 06 . 8 &lt;STRONG&gt;6&lt;/STRONG&gt;&lt;BR /&gt;B 2006 03 . 2 1&lt;BR /&gt;B 2006 03 12 7 &lt;STRONG&gt;1&lt;/STRONG&gt;&lt;BR /&gt;B 2006 03 10 &lt;STRONG&gt;7&lt;/STRONG&gt; &lt;STRONG&gt;1&lt;/STRONG&gt;&lt;BR /&gt;B 2007 03 9 1 2&lt;BR /&gt;B 2007 03 1 &lt;STRONG&gt;1&lt;/STRONG&gt; &lt;STRONG&gt;2&lt;/STRONG&gt;&lt;BR /&gt;B 2007 03 &lt;STRONG&gt;1&lt;/STRONG&gt; 3 4&lt;BR /&gt;B 2007 03 &lt;STRONG&gt;1&lt;/STRONG&gt; &lt;STRONG&gt;3&lt;/STRONG&gt; &lt;STRONG&gt;4&lt;/STRONG&gt;&lt;BR /&gt;B 2007 03 &lt;STRONG&gt;1&lt;/STRONG&gt; 3 4&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So there are two requirements when filling the missing value:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Fill the missing value of each variable by 'firm' with previous data.&lt;/P&gt;&lt;P&gt;2. If the number of missing value &amp;gt; 5, then we do not fill that variable. In this case, because the number of the missing value of value1 of firm A &amp;gt; 5, then it will not be filled by the lasted data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much.&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>Thu, 06 Jun 2019 04:47:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-fill-missing-value-less-of-variables-with-the-number-of/m-p/563964#M74989</guid>
      <dc:creator>Maomao_Hui</dc:creator>
      <dc:date>2019-06-06T04:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill missing value less of variables with the number of missing value less than 3.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-fill-missing-value-less-of-variables-with-the-number-of/m-p/563969#M74990</link>
      <description>&lt;P&gt;Please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input firm $2. year Month value1 value2 value3;
cards;
A 2006 03 7 7 5
A 2006 03 8 8 .
A 2006 03 . 9 1
A 2006 06 5 . .
A 2006 06 8 7 4
A 2006 06 . 4 3
A 2006 09 . . 2
A 2006 09 9 7 1
A 2006 09 . . 5
A 2007 03 . 7 .
A 2007 03 . 7 8
A 2007 03 . 7 .
A 2007 06 . 3 2
A 2007 06 . 7 6
A 2007 06 . 8 .
B 2006 03 . 2 1
B 2006 03 12 7 .
B 2006 03 10 . .
B 2007 03 9 1 2
B 2007 03 1 . .
B 2007 03 . 3 4
B 2007 03 . . .
B 2007 03 . 3 4
;
run;

proc sort data=test;;
by firm year month;
run;

data want;
set test;
by firm year month;
retain newvalue1 newvalue2 newvalue3;
if first.firm then do;newvalue1=.;newvalue2=.;newvalue3=.;end;
if value1 ne . then newvalue1=value1;
if value2 ne . then newvalue2=value2;
if value3 ne . then newvalue3=value3;
if value1 eq . and newvalue1 &amp;gt;5 then newvalue1=.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jun 2019 05:37:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-fill-missing-value-less-of-variables-with-the-number-of/m-p/563969#M74990</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-06-06T05:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill missing value less of variables with the number of missing value less than 3.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-fill-missing-value-less-of-variables-with-the-number-of/m-p/564058#M74991</link>
      <description>&lt;P&gt;Untested but should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have;
   by firm;
   var value1 value2 value3;
   output out=missing_count (drop=_type_ _freq_) nmiss=mis_val1 mis_val2 mis_val3;
run;

data want;
   merge have missing_count;
   by firm;
   if first.firm then do;
      replacement_val1 = .;
      replacement_val2 = .;
      replacement_val3 = .;
   end;
   retain replacement_val: ;
   drop replacement_val:  mis_val: ;
   if mis_val1 &amp;lt;= 5 and value1 &amp;gt; . then replacement_val1 = value1;
   if mis_val2 &amp;lt;= 5 and value2 &amp;gt; . then replacement_val2 = value2;
   if mis_val3 &amp;lt;= 5 and value3 &amp;gt; . then replacement_val3 = value3;
   if value1 = . then value1 = replacement_val1;
   if value2 = . then value2 = replacement_val2;
   if value3 = . then value3 = replacement_val3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Test it and see if you run into any problems.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2019 12:47:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-fill-missing-value-less-of-variables-with-the-number-of/m-p/564058#M74991</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-06-06T12:47:05Z</dc:date>
    </item>
  </channel>
</rss>

