<?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: Fillng in Missing Values based on previous observations in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Fillng-in-Missing-Values-based-on-previous-observations/m-p/274979#M7694</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a LAG function in SAS that allows you to reference the value of a variable on the previous observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is well documented and works along the lines of&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080"&gt;&lt;EM&gt;If date = . then date = lag(date) + 1;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Fri, 03 Jun 2016 15:03:58 GMT</pubDate>
    <dc:creator>rivieralad</dc:creator>
    <dc:date>2016-06-03T15:03:58Z</dc:date>
    <item>
      <title>Fillng in Missing Values based on previous observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Fillng-in-Missing-Values-based-on-previous-observations/m-p/274969#M7693</link>
      <description>&lt;P&gt;I need to replace missing values in my data set. I need SAS to reference the previous observation and calculate the date of the current observation based on the previous observation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data Example; set Example1;&lt;BR /&gt;If Date = "." then do;&lt;BR /&gt;Date = Obs - 1 ....... Date+1;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2016 14:45:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Fillng-in-Missing-Values-based-on-previous-observations/m-p/274969#M7693</guid>
      <dc:creator>llt34c</dc:creator>
      <dc:date>2016-06-03T14:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Fillng in Missing Values based on previous observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Fillng-in-Missing-Values-based-on-previous-observations/m-p/274979#M7694</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a LAG function in SAS that allows you to reference the value of a variable on the previous observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is well documented and works along the lines of&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080"&gt;&lt;EM&gt;If date = . then date = lag(date) + 1;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2016 15:03:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Fillng-in-Missing-Values-based-on-previous-observations/m-p/274979#M7694</guid>
      <dc:creator>rivieralad</dc:creator>
      <dc:date>2016-06-03T15:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: Fillng in Missing Values based on previous observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Fillng-in-Missing-Values-based-on-previous-observations/m-p/275103#M7699</link>
      <description>&lt;P&gt;Use a retained variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
retain previousDate;
set have;
date = coalesce(date, intnx("DAY", previousDate, 1));
previousDate = date;
drop previousDate;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Jun 2016 20:06:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Fillng-in-Missing-Values-based-on-previous-observations/m-p/275103#M7699</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-06-03T20:06:10Z</dc:date>
    </item>
  </channel>
</rss>

