<?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: Replace missing value with previous value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286772#M58900</link>
    <description>&lt;P&gt;Are you looking for something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input subid$ startdate enddate;
informat startdate enddate yymmdd10.;
format startdate enddate yymmddd10.;
datalines;
XYZ-123-001-001  2013-04-04 2013-04-05
XYZ-123-001-001  2013-05-23 .
XYZ-123-001-001  2013-06-07 2013-06-13
XYZ-123-001-001  2013-06-09 2013-06-15
XYZ-123-001-001  2013-07-07 .
XYZ-123-001-001  2013-07-27 .
XYZ-123-001-001  2013-08-07 2013-08-13
;
run;

data want;
set have;
retain keepdate;
if enddate ne .
then keepdate = enddate;
else enddate = keepdate;
drop keepdate;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But it will create enddates that make no sense, so could you be a little more specific about the rules, or provide an example "want" dataset?&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jul 2016 06:32:53 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-07-25T06:32:53Z</dc:date>
    <item>
      <title>Replace missing value with previous value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286766#M58896</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to get each date&amp;nbsp;with non-missing dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My approach is if I can replace missing dates&amp;nbsp;to the previous no-missing value, &amp;nbsp;However, I'm having difficulty to replace these missing value.,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;input subid$ startdate enddate;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;XYZ-123-001-001 &amp;nbsp;2013-04-04 2013-04-05&lt;/P&gt;&lt;P&gt;XYZ-123-001-001 &amp;nbsp;2013-05-23&amp;nbsp;.&lt;/P&gt;&lt;P&gt;XYZ-123-001-001 &amp;nbsp;2013-06-07 2013-06-13&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;XYZ-123-001-001 &amp;nbsp;2013-06-09 2013-06-15&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;XYZ-123-001-001 &amp;nbsp;2013-07-07&amp;nbsp;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;XYZ-123-001-001 &amp;nbsp;2013-07-27&amp;nbsp;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;XYZ-123-001-001 &amp;nbsp;2013-08-07 2013-08-13&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 06:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286766#M58896</guid>
      <dc:creator>gowtham112</dc:creator>
      <dc:date>2016-07-25T06:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing value with previous value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286772#M58900</link>
      <description>&lt;P&gt;Are you looking for something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input subid$ startdate enddate;
informat startdate enddate yymmdd10.;
format startdate enddate yymmddd10.;
datalines;
XYZ-123-001-001  2013-04-04 2013-04-05
XYZ-123-001-001  2013-05-23 .
XYZ-123-001-001  2013-06-07 2013-06-13
XYZ-123-001-001  2013-06-09 2013-06-15
XYZ-123-001-001  2013-07-07 .
XYZ-123-001-001  2013-07-27 .
XYZ-123-001-001  2013-08-07 2013-08-13
;
run;

data want;
set have;
retain keepdate;
if enddate ne .
then keepdate = enddate;
else enddate = keepdate;
drop keepdate;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But it will create enddates that make no sense, so could you be a little more specific about the rules, or provide an example "want" dataset?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 06:32:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286772#M58900</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-07-25T06:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing value with previous value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286776#M58901</link>
      <description>&lt;P&gt;Your end date is before your start date. I don't think that makes sense.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are the values missing?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 06:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286776#M58901</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-25T06:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing value with previous value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286898#M58940</link>
      <description>&lt;P&gt;Something else to consider: What if the first record for a subject is missing the enddate? Your basic rule would be using the enddate from another subject.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might consider adding a fixed number of days or advancing to end of month or similar rule for missing enddates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And do you have any missing start dates?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 15:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286898#M58940</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-25T15:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing value with previous value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286913#M58946</link>
      <description>&lt;P&gt;Thank you Kurtbremser ,for your valuable suggestion &amp;nbsp;actually i want to create TEAE flag inorder to do that i want end dates so &amp;nbsp;in my dataset some of end dates are missing so i want that missing dates to create..&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 16:01:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286913#M58946</guid>
      <dc:creator>gowtham112</dc:creator>
      <dc:date>2016-07-25T16:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing value with previous value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286915#M58947</link>
      <description>Thank you Reeza for your valuable suggestion actually in my data no end date was before start date.Actually i want to create TEAE flag to do so i want end&lt;BR /&gt;dates.. so i want to replace those missing values to create TEAE...</description>
      <pubDate>Mon, 25 Jul 2016 16:07:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286915#M58947</guid>
      <dc:creator>gowtham112</dc:creator>
      <dc:date>2016-07-25T16:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing value with previous value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286920#M58950</link>
      <description>Thank you Ballardw for your suggestion, In my data there were no missing start dates ,Can you suggest me how to replace end date with end of month.</description>
      <pubDate>Mon, 25 Jul 2016 16:23:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/286920#M58950</guid>
      <dc:creator>gowtham112</dc:creator>
      <dc:date>2016-07-25T16:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing value with previous value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/287007#M58983</link>
      <description>&lt;P&gt;Not the only way but&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if missing enddate then enddate= intnx('month',startdate,1)-1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will give the end day of the month assuming the date variables are actually SAS date values.&lt;/P&gt;
&lt;P&gt;This works by the default advance a date by one month gets to the first day of the following month. Subtracting one gets one day before.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or&lt;/P&gt;
&lt;P&gt;enddate= intnx('month', startdate,0,'e');&amp;nbsp;&amp;nbsp; uses the alignment 'e', for end of month, and advances 0 months(i.e. the same month).&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 22:17:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/287007#M58983</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-25T22:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing value with previous value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/287011#M58985</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/93916"&gt;@gowtham112﻿&lt;/a&gt;&amp;nbsp;FYI -&amp;nbsp;You don't need to reply to each post individually. It makes the thread very hard to read.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 19:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-value-with-previous-value/m-p/287011#M58985</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-25T19:54:51Z</dc:date>
    </item>
  </channel>
</rss>

