<?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 Fill down row if missing for all variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Fill-down-row-if-missing-for-all-variables/m-p/684436#M207405</link>
    <description>&lt;P&gt;Hello. I have the following data:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id day1 day2 day3 day4 otherd7;
datalines;
1 -11 -10 -9 -8 0
1 -7 -6 . . .
2 -20 -19 -18 -17 1
2 -16 . . . .
3 -8 -7 -6 -5 .
3 -4 . . . .
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I would like the following data:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input id day1 day2 day3 day4 otherd7;
datalines;
1 -11 -10 -9 -8 0
1 -7 -6 -10 -9 0
2 -20 -19 -18 -17 1
2 -16 -19 -18 -17 1
3 -8 -7 -6 -5 .
3 -4 -7 -6 -5 .
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is just a sample of the variables in the table. I would like to do this for every variable in the table. Each ID has 2 observations. Essentially, I would like to "fill down" if the value in last.id is missing. Could someone please help me with some code. I figured out how to do this for one variable at a time, but cannot figure out how to do it for all the variables in one easy step. Thank you.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Sep 2020 00:25:00 GMT</pubDate>
    <dc:creator>eabc0351</dc:creator>
    <dc:date>2020-09-17T00:25:00Z</dc:date>
    <item>
      <title>Fill down row if missing for all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-down-row-if-missing-for-all-variables/m-p/684436#M207405</link>
      <description>&lt;P&gt;Hello. I have the following data:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id day1 day2 day3 day4 otherd7;
datalines;
1 -11 -10 -9 -8 0
1 -7 -6 . . .
2 -20 -19 -18 -17 1
2 -16 . . . .
3 -8 -7 -6 -5 .
3 -4 . . . .
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I would like the following data:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input id day1 day2 day3 day4 otherd7;
datalines;
1 -11 -10 -9 -8 0
1 -7 -6 -10 -9 0
2 -20 -19 -18 -17 1
2 -16 -19 -18 -17 1
3 -8 -7 -6 -5 .
3 -4 -7 -6 -5 .
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is just a sample of the variables in the table. I would like to do this for every variable in the table. Each ID has 2 observations. Essentially, I would like to "fill down" if the value in last.id is missing. Could someone please help me with some code. I figured out how to do this for one variable at a time, but cannot figure out how to do it for all the variables in one easy step. Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 00:25:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-down-row-if-missing-for-all-variables/m-p/684436#M207405</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2020-09-17T00:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: Fill down row if missing for all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-down-row-if-missing-for-all-variables/m-p/684437#M207406</link>
      <description>Quick edit -- the first row is supposed to be:&lt;BR /&gt;1 -11 -10 -9 -8 0&lt;BR /&gt;1 -7 -6 -9 -8 0</description>
      <pubDate>Thu, 17 Sep 2020 00:27:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-down-row-if-missing-for-all-variables/m-p/684437#M207406</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2020-09-17T00:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Fill down row if missing for all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-down-row-if-missing-for-all-variables/m-p/684442#M207409</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id day1 day2 day3 day4 otherd7;
datalines;
1 -11 -10 -9 -8 0
1 -7 -6 . . .
2 -20 -19 -18 -17 1
2 -16 . . . .
3 -8 -7 -6 -5 .
3 -4 . . . .
;
run;

data want;
  update have(obs=0) have;
  by id;
  output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Sep 2020 00:34:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-down-row-if-missing-for-all-variables/m-p/684442#M207409</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-09-17T00:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Fill down row if missing for all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-down-row-if-missing-for-all-variables/m-p/684444#M207410</link>
      <description>Oh that was so easy. I tried it but had the code a little off. Thank you!</description>
      <pubDate>Thu, 17 Sep 2020 00:40:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-down-row-if-missing-for-all-variables/m-p/684444#M207410</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2020-09-17T00:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: Fill down row if missing for all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-down-row-if-missing-for-all-variables/m-p/684446#M207412</link>
      <description>&lt;P&gt;Glad you made that correction, I was having trouble replicating it.&amp;nbsp; Here is a fairly elegant solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data mywant;
  set have;
  array toretain day1 day2 day3 day4 otherd7;
  by id;
  do over toretain;
    junk = lag(toretain);
    toretain = coalesce(toretain,junk);
  end;
  output;
  if last.id then do over toretain;
    toretain = .;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;Note that the real trick is setting junk = to the lag.&amp;nbsp; Lag only works if it is called every row.&amp;nbsp; If the lag was in the coalesce will not call it if the current row has a value.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 00:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-down-row-if-missing-for-all-variables/m-p/684446#M207412</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-17T00:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Fill down row if missing for all variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-down-row-if-missing-for-all-variables/m-p/684447#M207413</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339357"&gt;@CurtisMackWSIPP&lt;/a&gt;, I will give that a try as well.&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Sep 2020 00:55:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-down-row-if-missing-for-all-variables/m-p/684447#M207413</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2020-09-17T00:55:43Z</dc:date>
    </item>
  </channel>
</rss>

