<?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: SAS data - fill missing value with existing observation for same ID in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/SAS-data-fill-missing-value-with-existing-observation-for-same/m-p/834633#M35895</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id city $ year status @@;
datalines;
1 A 1990 .
1 B 1995 .
1 C 2000 1
1 D 2001 .
2 C 1985 .
2 F 2011 .
3 A 1999 .
3 B 2000 1
3 E 2011 1
3 F 2012 .
;
run;

PROC FREQ data=have;
 tables id * status / list missing out=work.count(where=(status NE .));
run;

data want;
 merge have count(keep=id /* status */ in=incount);
 by id;
 if incount then status=1;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
    <pubDate>Thu, 22 Sep 2022 10:28:09 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2022-09-22T10:28:09Z</dc:date>
    <item>
      <title>SAS data - fill missing value with existing observation for same ID</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-data-fill-missing-value-with-existing-observation-for-same/m-p/834627#M35894</link>
      <description>&lt;P&gt;Closed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 15:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-data-fill-missing-value-with-existing-observation-for-same/m-p/834627#M35894</guid>
      <dc:creator>hellorc</dc:creator>
      <dc:date>2022-09-22T15:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS data - fill missing value with existing observation for same ID</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-data-fill-missing-value-with-existing-observation-for-same/m-p/834633#M35895</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id city $ year status @@;
datalines;
1 A 1990 .
1 B 1995 .
1 C 2000 1
1 D 2001 .
2 C 1985 .
2 F 2011 .
3 A 1999 .
3 B 2000 1
3 E 2011 1
3 F 2012 .
;
run;

PROC FREQ data=have;
 tables id * status / list missing out=work.count(where=(status NE .));
run;

data want;
 merge have count(keep=id /* status */ in=incount);
 by id;
 if incount then status=1;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 10:28:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-data-fill-missing-value-with-existing-observation-for-same/m-p/834633#M35895</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-09-22T10:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS data - fill missing value with existing observation for same ID</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-data-fill-missing-value-with-existing-observation-for-same/m-p/834634#M35896</link>
      <description>&lt;P&gt;And another way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   
   if _n_ = 1 then do;
      declare hash h(dataset: 'work.have(keep= id status where=(not missing(Status)))');
      h.defineKey('id');
      h.defineData('status');
      h.defineDone();
   end;
   
   rc = h.find();
   
   drop rc;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Sep 2022 10:52:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-data-fill-missing-value-with-existing-observation-for-same/m-p/834634#M35896</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-09-22T10:52:31Z</dc:date>
    </item>
  </channel>
</rss>

