<?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 Filling up and down missing values with non-missing values in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Filling-up-and-down-missing-values-with-non-missing-values/m-p/294911#M8336</link>
    <description>&lt;P&gt;Hello SAS community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am desperately trying to figure out how to replace missing values with non-missing values based on a given condition. To be more precise, we fill in a missing value if the time difference between its corresponding date and adjacent date is less than a month; and we leave it as missing if it's one month or over apart. For instance, the following dot should be replaced with 1 since the time difference is less than a month:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;09jan2016 1
15jan2016 .&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;On the other hand, the following dot should be left as missing as the two events happened over a span of more than one month:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;21may2016 .
10jul2016 1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now, here is a subset of the data set I'm dealing with in my workplace:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data my_data;
input ID Birthday date9. tpin;
label tpin="Temporary Personal Identification Number";
cards;
1 31mar1990 .
1 13apr1990 .
1 20apr1990 0
1 04jun1990 .
1 08jun1990 .
1 19jun1990 1
1 01jul1990 .
1 06aug1990 .
1 13aug1990 2
1 22feb1991 .
2 28feb1991 1
2 15apr1991 .
2 20may1991 0
2 25may1991 .
2 01jun1991 .
2 18jun1991 2
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you've understood the rules to apply, the final table should look like this after an up and down algorithm, for each ID:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1 31mar1990 0
1 13apr1990 0
1 20apr1990 0
1 04jun1990 1
1 08jun1990 1
1 19jun1990 1
1 01jul1990 1
1 06aug1990 2
1 13aug1990 2
1 22feb1991 .
2 28feb1991 1
2 15apr1991 .
2 20may1991 0
2 25may1991 0
2 01jun1991 2
2 18jun1991 2&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I've tried absolutely everything (merge, update, SQL etc.), unfortunately none of them yields the desired results. I'll be really grateful if anyone could help me out!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
    <pubDate>Mon, 29 Aug 2016 18:45:14 GMT</pubDate>
    <dc:creator>expertyejin</dc:creator>
    <dc:date>2016-08-29T18:45:14Z</dc:date>
    <item>
      <title>Filling up and down missing values with non-missing values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Filling-up-and-down-missing-values-with-non-missing-values/m-p/294911#M8336</link>
      <description>&lt;P&gt;Hello SAS community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am desperately trying to figure out how to replace missing values with non-missing values based on a given condition. To be more precise, we fill in a missing value if the time difference between its corresponding date and adjacent date is less than a month; and we leave it as missing if it's one month or over apart. For instance, the following dot should be replaced with 1 since the time difference is less than a month:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;09jan2016 1
15jan2016 .&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;On the other hand, the following dot should be left as missing as the two events happened over a span of more than one month:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;21may2016 .
10jul2016 1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now, here is a subset of the data set I'm dealing with in my workplace:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data my_data;
input ID Birthday date9. tpin;
label tpin="Temporary Personal Identification Number";
cards;
1 31mar1990 .
1 13apr1990 .
1 20apr1990 0
1 04jun1990 .
1 08jun1990 .
1 19jun1990 1
1 01jul1990 .
1 06aug1990 .
1 13aug1990 2
1 22feb1991 .
2 28feb1991 1
2 15apr1991 .
2 20may1991 0
2 25may1991 .
2 01jun1991 .
2 18jun1991 2
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you've understood the rules to apply, the final table should look like this after an up and down algorithm, for each ID:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1 31mar1990 0
1 13apr1990 0
1 20apr1990 0
1 04jun1990 1
1 08jun1990 1
1 19jun1990 1
1 01jul1990 1
1 06aug1990 2
1 13aug1990 2
1 22feb1991 .
2 28feb1991 1
2 15apr1991 .
2 20may1991 0
2 25may1991 0
2 01jun1991 2
2 18jun1991 2&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I've tried absolutely everything (merge, update, SQL etc.), unfortunately none of them yields the desired results. I'll be really grateful if anyone could help me out!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 18:45:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Filling-up-and-down-missing-values-with-non-missing-values/m-p/294911#M8336</guid>
      <dc:creator>expertyejin</dc:creator>
      <dc:date>2016-08-29T18:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Filling up and down missing values with non-missing values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Filling-up-and-down-missing-values-with-non-missing-values/m-p/294932#M8337</link>
      <description>&lt;P&gt;You don't describe the rule for getting 31Mar1990 and 13Apr1990 to 0.&lt;/P&gt;
&lt;P&gt;Also, are your dates actually SAS date values or character? From what you are displaying I would guess character.&lt;/P&gt;
&lt;P&gt;When you have SAS date values there are lots of tools to calculate intervals and such.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 20:11:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Filling-up-and-down-missing-values-with-non-missing-values/m-p/294932#M8337</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-29T20:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Filling up and down missing values with non-missing values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Filling-up-and-down-missing-values-with-non-missing-values/m-p/294975#M8338</link>
      <description>&lt;P&gt;Dates are definitely in numeric (date9.) format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And as far as the rule is concerned, the tpin value for 31Mar1990 is assigned 0 because it is less than a month from 13Apr1990, which itself had been assigned a 0 because it is less than a month from 20Apr1990.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2016 21:19:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Filling-up-and-down-missing-values-with-non-missing-values/m-p/294975#M8338</guid>
      <dc:creator>expertyejin</dc:creator>
      <dc:date>2016-08-29T21:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Filling up and down missing values with non-missing values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Filling-up-and-down-missing-values-with-non-missing-values/m-p/295040#M8339</link>
      <description>&lt;PRE&gt;


data my_data;
input ID Birthday date9. tpin;
format Birthday date9.;
label tpin="Temporary Personal Identification Number";
cards;
1 31mar1990 .
1 13apr1990 .
1 20apr1990 0
1 04jun1990 .
1 08jun1990 .
1 19jun1990 1
1 01jul1990 .
1 06aug1990 .
1 13aug1990 2
1 22feb1991 .
2 28feb1991 1
2 15apr1991 .
2 20may1991 0
2 25may1991 .
2 01jun1991 .
2 18jun1991 2
;
run;
proc sort data=my_data;by id Birthday;run;
data temp;
 set my_data;
 by id;
 dif_month=Birthday gt intnx('month',lag(Birthday),1,'s') ;
 if first.id then dif_month=.;
run;
data temp1;
 set temp;
 by id;
 if first.id or dif_month=1 then group+1;
 drop dif_month;
run;
data temp1;
 set temp1;
 by id group;
 retain temp;
 if first.group then call missing(temp);
 if not missing(tpin) then temp=tpin;
run;
proc sort data=temp1;by id descending Birthday;run;
data want;
 set temp1;
 by id group notsorted;
 retain want;
 if first.group then call missing(want);
 if not missing(temp) then want=temp;
 drop temp ;
run;
proc sort data=want;by id Birthday;run;



&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Aug 2016 04:00:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Filling-up-and-down-missing-values-with-non-missing-values/m-p/295040#M8339</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-30T04:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: Filling up and down missing values with non-missing values</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Filling-up-and-down-missing-values-with-non-missing-values/m-p/295050#M8340</link>
      <description>&lt;P&gt;How amazing! I can't believe it works! Thank you so much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 05:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Filling-up-and-down-missing-values-with-non-missing-values/m-p/295050#M8340</guid>
      <dc:creator>expertyejin</dc:creator>
      <dc:date>2016-08-30T05:10:44Z</dc:date>
    </item>
  </channel>
</rss>

