<?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 row with last non blank entry by group in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618942#M19303</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input ID    Date :mmddyy10.;
format date mmddyy10.;
cards;
1    .
1    .
1   .
1   01/17/2020
1    .
1    .
1   .
1   01/21/2020
2   01/18/2019
;
data temp;
 set have curobs=k;
 by id;
 if first.id then n=0;
 rn=k;
 if lag(date)&amp;gt;. and missing(date) and not first.id then n+1;
run;

proc sql;
create table want(drop=n) as
select id,n,max(date) as date format=mmddyy10.
from temp
group by id,n
order by rn;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 21 Jan 2020 19:42:50 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-01-21T19:42:50Z</dc:date>
    <item>
      <title>Fill row with last non blank entry by group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618929#M19297</link>
      <description>&lt;P&gt;Using SAS 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have data that looks like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; Date&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;01/21/2020&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to fill the column so that it looks like this:&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; Date&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;&amp;nbsp;01/21/2020&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;&amp;nbsp;01/21/2020&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;01/21/2020&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;01/21/2020&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried this code&lt;/P&gt;&lt;P&gt;data test_set;&lt;BR /&gt;set have;&lt;BR /&gt;by record_id;&lt;BR /&gt;retain _phone_date;&lt;BR /&gt;if not missing (phone_date) then _phone_date = phone_date;&lt;BR /&gt;else phone_date = _phone_date;&lt;BR /&gt;drop _phone_date;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However this retains the non blank date from above, is there a method to retain the date from below? Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 19:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618929#M19297</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-01-21T19:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Fill row with last non blank entry by group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618934#M19300</link>
      <description>Could you just resort your data so that the blanks are at the end? I'm assuming you have other variables in this data set though, could they help with the sort?&lt;BR /&gt;&lt;BR /&gt;If you have SAS ETS/PROC TIMESERIES could possibly fill it in as well.</description>
      <pubDate>Tue, 21 Jan 2020 19:13:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618934#M19300</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-01-21T19:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Fill row with last non blank entry by group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618936#M19302</link>
      <description>&lt;P&gt;I tried that and get an error that my by variable is not properly sorted&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 19:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618936#M19302</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-01-21T19:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Fill row with last non blank entry by group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618942#M19303</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input ID    Date :mmddyy10.;
format date mmddyy10.;
cards;
1    .
1    .
1   .
1   01/17/2020
1    .
1    .
1   .
1   01/21/2020
2   01/18/2019
;
data temp;
 set have curobs=k;
 by id;
 if first.id then n=0;
 rn=k;
 if lag(date)&amp;gt;. and missing(date) and not first.id then n+1;
run;

proc sql;
create table want(drop=n) as
select id,n,max(date) as date format=mmddyy10.
from temp
group by id,n
order by rn;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jan 2020 19:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618942#M19303</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-21T19:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Fill row with last non blank entry by group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618948#M19304</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194348"&gt;@GS2&lt;/a&gt;&amp;nbsp; Some Hash fun&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input ID    Date :mmddyy10.;
format date mmddyy10.;
cards;
1    .
1    .
1   .
1   01/17/2020
1    .
1    .
1   .
1   01/21/2020
2   01/18/2019
2   .
2   01/22/2019
3   01/19/2019
3   .
3   01/23/2019
;

data want;
 if _n_=1 then do;
  dcl hash H (multidata:'y') ;
  h.definekey  ("id") ;
  h.definedata ("_iorc_") ;
  h.definedone () ;
 end;
 do _n_=1 by 1 until(last.id);
  set have end=z;
  by id;
  _iorc_=date;
  if _iorc_ then h.add();
 end;
 do _n_=1 to _n_;
  set have;
  if h.find()=0 and date=_iorc_ then h.removedup();
  date=_iorc_;
  output;
 end;
 h.clear();
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 20:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618948#M19304</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-21T20:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: Fill row with last non blank entry by group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618949#M19305</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID    Date :mmddyy10.;
format date mmddyy10.;
cards;
1    .
1    .
1   .
1   01/21/2020
1    .
1    .
1   .
2   01/18/2019
;
run;

proc sort data=have;
 by id descending Date ;
run;

data want;
update have(obs=0) have;
by id;
output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jan 2020 20:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618949#M19305</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2020-01-21T20:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Fill row with last non blank entry by group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618955#M19307</link>
      <description>&lt;P&gt;I am going to be honest that coding may be above my skill level.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 20:33:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618955#M19307</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-01-21T20:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Fill row with last non blank entry by group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618956#M19308</link>
      <description>&lt;P&gt;This did not produce the results I wanted. It retained a date from the row above, which is from a different correct and therefore an incorrect date.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 20:34:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618956#M19308</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-01-21T20:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: Fill row with last non blank entry by group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618957#M19309</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194348"&gt;@GS2&lt;/a&gt;&amp;nbsp; Prolly for the time being it is, but a fork lift driver with no formal comp/math/stat education before SAS can do it, you certainly can. Have that confidence. All the best!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 20:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618957#M19309</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-21T20:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Fill row with last non blank entry by group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618958#M19310</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194348"&gt;@GS2&lt;/a&gt;&amp;nbsp; Please see if the simple approach below works for you. I think this is easy to follow and ,modify/edit to your needs. Please let us know if we can be of more help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input ID    Date :mmddyy10.;
format date mmddyy10.;
cards;
1    .
1    .
1   .
1   01/17/2020
1    .
1    .
1   .
1   01/21/2020
2   01/18/2019
2   .
2   01/22/2019
3   01/19/2019
3   .
3   01/23/2019
;
/*Get the rownumber*/
data temp;
set have curobs=k;
rownum=k;
run;

proc sort data=temp out=temp2;
by  id descending rownum;
run;

data temp3;
 update temp2(obs=0) temp2;
 by id ;
 output;
run;

proc sort data=temp3 out=want;
by rownum;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jan 2020 20:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618958#M19310</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-21T20:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Fill row with last non blank entry by group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618966#M19311</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input ID    Date :mmddyy10.;
format date mmddyy10.;
cards;
1    .
1    .
1   .
1   01/17/2020
1    .
1    .
1   .
1   01/21/2020
2   01/18/2019
2   .
2   01/22/2019
3   01/19/2019
3   .
3   01/23/2019
;
run;

data want(rename=(date=date_old date2=date ));
array id_{1:10} _temporary_;

format date2 date9.;
do _n_=1 by 1 until(last.id | ^ missing(date))  ;
	set have;
	by id;

	id_[id]=date; 
end;

do until(last.id | ^missing(date));
	set have;
	by id;
	date2=id_[id]; output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jan 2020 21:21:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Fill-row-with-last-non-blank-entry-by-group/m-p/618966#M19311</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2020-01-21T21:21:10Z</dc:date>
    </item>
  </channel>
</rss>

