<?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 NA with next value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Fill-NA-with-next-value/m-p/758799#M239664</link>
    <description>Things are never as simple as they seem, right?</description>
    <pubDate>Mon, 02 Aug 2021 14:23:21 GMT</pubDate>
    <dc:creator>maguiremq</dc:creator>
    <dc:date>2021-08-02T14:23:21Z</dc:date>
    <item>
      <title>Fill NA with next value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-NA-with-next-value/m-p/758739#M239638</link>
      <description>&lt;P&gt;I'd like to fill missing values with the previous one like in below example:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%" height="30px"&gt;Date&lt;/TD&gt;
&lt;TD width="50%" height="30px"&gt;Value&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="30px"&gt;2021-08-01&lt;/TD&gt;
&lt;TD height="30px"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="30px"&gt;2021-08-02&lt;/TD&gt;
&lt;TD width="50%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;Date&lt;/TD&gt;
&lt;TD width="50%"&gt;Value&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;2021-08-01&lt;/TD&gt;
&lt;TD width="50%"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;2021-08-02&lt;/TD&gt;
&lt;TD width="50%"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;How can I do it in a fast way?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Aug 2021 10:43:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-NA-with-next-value/m-p/758739#M239638</guid>
      <dc:creator>PatrykSAS</dc:creator>
      <dc:date>2021-08-02T10:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Fill NA with next value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-NA-with-next-value/m-p/758744#M239642</link>
      <description>&lt;P&gt;Please clarify your request.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the title, you say you want the NEXT value, but in your text you say you want the PREVIOUS value. These are not the same. Which is it?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Aug 2021 14:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-NA-with-next-value/m-p/758744#M239642</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-08-02T14:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Fill NA with next value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-NA-with-next-value/m-p/758779#M239661</link>
      <description>&lt;P&gt;You can do something like this, but I'm also quite certain that there are additional complexities that you didn't capture in your example. Nonetheless, try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines missover;
input date :yymmdd10. value;
format date yymmdd10.;
datalines;
2021/08/01 10
2021/08/02 .
;

data want;
	set have;
		lag_val = lag(value);
		if missing(value) then value = lag_val;
	drop lag_val;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;date value 
2021-08-01 10 
2021-08-02 10 
&lt;/PRE&gt;
&lt;P&gt;You can remove the&lt;/P&gt;
&lt;PRE&gt;drop lag_val;&lt;/PRE&gt;
&lt;P&gt;if you want to see what's going on.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Aug 2021 13:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-NA-with-next-value/m-p/758779#M239661</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-08-02T13:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: Fill NA with next value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-NA-with-next-value/m-p/758796#M239662</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;... but I'm also quite certain that there are additional complexities that you didn't capture in your example ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I'm glad you pointed that out&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281770"&gt;@maguiremq&lt;/a&gt;&amp;nbsp;, I was thinking the same thing.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Aug 2021 14:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-NA-with-next-value/m-p/758796#M239662</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-08-02T14:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Fill NA with next value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-NA-with-next-value/m-p/758799#M239664</link>
      <description>Things are never as simple as they seem, right?</description>
      <pubDate>Mon, 02 Aug 2021 14:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-NA-with-next-value/m-p/758799#M239664</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-08-02T14:23:21Z</dc:date>
    </item>
  </channel>
</rss>

