<?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 up missing values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253470#M48242</link>
    <description>&lt;P&gt;thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 01 Mar 2016 15:55:00 GMT</pubDate>
    <dc:creator>madelman</dc:creator>
    <dc:date>2016-03-01T15:55:00Z</dc:date>
    <item>
      <title>fill up missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253340#M48191</link>
      <description>&lt;P&gt;Hi, hopefully this will be a relatively easy question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set with the following format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID &amp;nbsp; &amp;nbsp;status&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6&lt;/P&gt;&lt;P&gt;etc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;would like to get it like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID &amp;nbsp; &amp;nbsp;status&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;pretty much need to fill "up" the rows instead of down. any thoughts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 03:54:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253340#M48191</guid>
      <dc:creator>madelman</dc:creator>
      <dc:date>2016-03-01T03:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: fill up missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253341#M48192</link>
      <description>&lt;P&gt;If you only have one value per ID, you can use a&amp;nbsp;summary function within SQL to obtain the value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See the example below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *, max(status) as status2
from have
group by ID;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Mar 2016 04:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253341#M48192</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-01T04:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: fill up missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253361#M48199</link>
      <description>&lt;P&gt;There are many scenario you need to consider about .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID    status;
cards;
1        . 
1        .
1        . 
1        5
2        .
2        .
2        6
;
run;

data want;
 do until(not missing(status) or last.id );
  set have;
  by id;  
 end;
 temp=status;
 do until(not missing(status) or last.id );
  set have;
  by id;
  _status=temp;output;
 end;
 drop temp status;
run;
 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Mar 2016 07:57:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253361#M48199</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-01T07:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: fill up missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253470#M48242</link>
      <description>&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 15:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253470#M48242</guid>
      <dc:creator>madelman</dc:creator>
      <dc:date>2016-03-01T15:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: fill up missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253490#M48248</link>
      <description>&lt;P&gt;This works as long as it's always the last observation (per ID) that contains a nonmissing value.&amp;nbsp; If a nonmissing value comes earlier, you will run into trouble.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 16:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253490#M48248</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-01T16:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: fill up missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253567#M48283</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;This works as long as it's always the last observation (per ID) that contains a nonmissing value.&amp;nbsp; If a nonmissing value comes earlier, you will run into trouble.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I believe you are wrong about that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2121iA201739214A5E122/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&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>Tue, 01 Mar 2016 19:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253567#M48283</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-03-01T19:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: fill up missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253571#M48285</link>
      <description>&lt;P&gt;Now try it with a slight variation to the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; Status&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;3&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;3&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;3&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 19:37:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253571#M48285</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-01T19:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: fill up missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253632#M48295</link>
      <description>&lt;P&gt;As expected. &amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/72337"&gt;@madelman﻿&lt;/a&gt;&amp;nbsp;mentions only "filling-up".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2131iE61BC2858F29C920/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 23:13:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253632#M48295</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-03-01T23:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: fill up missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253685#M48304</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;, how would you deal with this data? the proc sql solution mentioned above didnt work for my data. thanks for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 04:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253685#M48304</guid>
      <dc:creator>madelman</dc:creator>
      <dc:date>2016-03-02T04:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: fill up missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253726#M48309</link>
      <description>&lt;P&gt;The PROC SQL solution works with Astounding's test data. If it doesn't work with &lt;EM&gt;your&lt;/EM&gt; data (incorrect output? error message in the log?), please post a sample of your data so that we can tell you how to fix the issue.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 09:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253726#M48309</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-03-02T09:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: fill up missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253742#M48310</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/72337"&gt;@madelman&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;, how would you deal with this data? the proc sql solution mentioned above didnt work for my data. thanks for your help.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/72337"&gt;@madelman&lt;/a&gt;&amp;nbsp;Are you now saying that you DO want to fill down too? &amp;nbsp;I think this modification of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;program will do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;title;
data have;
   input ID status @@; 
   cards;
1 . 1 . 1 5 1 .
2 4 2 . 2 . 
3 . 3 1 3 . 3 .
4 . 4 . 4 5 4 . 4 4 4 . 4 .
;
run;
proc print;
   run;

data want;
   if 0 then set have;
   do until(not missing(status) or last.id );
      set have;
      by id;  
      if first.id then ltemp=.;
      end;
   temp=status;
   do until(not missing(status) or last.id );
      set have;
      by id;
      _status=coalesce(temp,ltemp);
      output;
      end;
   retain ltemp;
   ltemp=temp;
   drop temp ltemp;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2137i5CBB1E8B171950AE/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 10:54:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253742#M48310</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-03-02T10:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: fill up missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253768#M48314</link>
      <description>&lt;P&gt;First, let me say that KSharp's solution is both elegant and satisfied the original request. I like his code, but wasn't sure if that original request actually illustrated all the conditions in the data that might occur.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To me, the real issue is the structure of the data originally. &amp;nbsp;For example, will there always be exactly one nonmissing STATUS per ID? &amp;nbsp;If so, you could code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;merge have (keep=ID) have (where=(status &amp;gt; .));&lt;/P&gt;
&lt;P&gt;by ID;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This also does no harm if an ID has all missing STATUS values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But this has flaws if there could be more than one nonmissing STATUS per ID. &amp;nbsp;So the question goes back to STATUS. &amp;nbsp;Could there be more than one value per ID? &amp;nbsp;What positions could it occupy? &amp;nbsp;If there are two, what value should be used? &amp;nbsp;(Does it matter?) &amp;nbsp;In particular, what values should be used if the data looks like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID &amp;nbsp; Status&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now there is a need to fill up, fill down, and fill in between. &amp;nbsp;The programming depends on the intended result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A better modification due to the likelihood that you have additional variables in the data&amp;amp;colon;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;merge have (drop=status) have (keep=id status where=(status &amp;gt; .));&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 15:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/253768#M48314</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-02T15:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: fill up missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/254855#M48646</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__﻿&lt;/a&gt;&amp;nbsp;that worked beautifully!&lt;/P&gt;</description>
      <pubDate>Sun, 06 Mar 2016 19:36:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/fill-up-missing-values/m-p/254855#M48646</guid>
      <dc:creator>madelman</dc:creator>
      <dc:date>2016-03-06T19:36:47Z</dc:date>
    </item>
  </channel>
</rss>

