<?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: Fill missing values with the first non-missing value in a row. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429352#M106057</link>
    <description>&lt;P&gt;That works! Thanks a lot! I should do more research on that.&lt;/P&gt;</description>
    <pubDate>Sat, 20 Jan 2018 06:19:16 GMT</pubDate>
    <dc:creator>sasecn</dc:creator>
    <dc:date>2018-01-20T06:19:16Z</dc:date>
    <item>
      <title>Fill missing values with the first non-missing value in a row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429346#M106051</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a b c d e&lt;/P&gt;&lt;P&gt;.&amp;nbsp; .&amp;nbsp; .&amp;nbsp; .&amp;nbsp; .&lt;/P&gt;&lt;P&gt;.&amp;nbsp; 1 2 3 4&lt;/P&gt;&lt;P&gt;.&amp;nbsp; .&amp;nbsp; 2 3 4&lt;/P&gt;&lt;P&gt;0 1 2 3 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to fill the missing values with the first non-missing value in each row. For each row, if all missing or there is no missing, there is nothing to do. But for all other cases, fill the missing value(s) with the first non-missing value. The result that I am looking for is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a b c d e&lt;/P&gt;&lt;P&gt;.&amp;nbsp; .&amp;nbsp; .&amp;nbsp; .&amp;nbsp; .&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/EM&gt; 1 2 3 4&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;2 2&lt;/STRONG&gt;&lt;/EM&gt; 2 3 4&lt;/P&gt;&lt;P&gt;0 1 2 3 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jan 2018 05:37:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429346#M106051</guid>
      <dc:creator>sasecn</dc:creator>
      <dc:date>2018-01-20T05:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Fill missing values with the first non-missing value in a row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429347#M106052</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

set have;

array t(*) a--e;

do _n_=1 to dim(t);

if t(_n_)=. then t(_n_)=coalesce(of t(*));

end;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Untested as i am away from my SAS software&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jan 2018 05:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429347#M106052</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-20T05:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Fill missing values with the first non-missing value in a row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429348#M106053</link>
      <description>&lt;P&gt;Now tested&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a b c d e;
datalines;
.  .  .  .  .
.  1 2 3 4
.  .  2 3 4
0 1 2 3 4
;

data want;
set have;
array t(*) a--e;
do _n_=1 to dim(t);
if t(_n_)=. then t(_n_)=coalesce(of t(*));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Jan 2018 05:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429348#M106053</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-20T05:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Fill missing values with the first non-missing value in a row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429349#M106054</link>
      <description>&lt;P&gt;Thanks for the quick reply. I still have problems. I actually have the values which are not numeric (i posted using numeric values to make it easy, but i guess i made a wrong decision). The exact data is like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;location1 location2 location3 location4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(missing)&amp;nbsp; &amp;nbsp;ON&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AB&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(missing)&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(missing)&amp;nbsp; &amp;nbsp; AB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ON&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(missing)&amp;nbsp;(missing)&amp;nbsp;(missing)&amp;nbsp;(missing)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ON&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ON&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The result will be:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;location1 location2 location3 location4&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;ON&amp;nbsp;&lt;/STRONG&gt; &lt;/EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ON&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AB&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;SPAN&gt;AB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AB&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ON&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(missing)&amp;nbsp;(missing)&amp;nbsp;(missing)&amp;nbsp;(missing)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ON&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ON&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried to modify your code by replacing the var names and replacing . to ' ' (i.e. numeric missing to char missing). I got some error message like:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;NOTE: Character values have been converted to numeric values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;159:39&lt;BR /&gt;NOTE: Numeric values have been converted to character values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ght that&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jan 2018 05:59:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429349#M106054</guid>
      <dc:creator>sasecn</dc:creator>
      <dc:date>2018-01-20T05:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Fill missing values with the first non-missing value in a row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429350#M106055</link>
      <description>&lt;P&gt;Thanks, that is great! I am sure that will help me for other questions! But why my modified code is not working on char values?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jan 2018 06:04:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429350#M106055</guid>
      <dc:creator>sasecn</dc:creator>
      <dc:date>2018-01-20T06:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Fill missing values with the first non-missing value in a row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429351#M106056</link>
      <description>&lt;P&gt;for char values use coalescec&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array t(*) location1-location4;
do _n_=1 to dim(t);
if missing(t(_n_)) then t(_n_)=coalescec(of t(*));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Jan 2018 06:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429351#M106056</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-20T06:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Fill missing values with the first non-missing value in a row.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429352#M106057</link>
      <description>&lt;P&gt;That works! Thanks a lot! I should do more research on that.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jan 2018 06:19:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-missing-values-with-the-first-non-missing-value-in-a-row/m-p/429352#M106057</guid>
      <dc:creator>sasecn</dc:creator>
      <dc:date>2018-01-20T06:19:16Z</dc:date>
    </item>
  </channel>
</rss>

