<?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 end date imputation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888045#M350868</link>
    <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help in programming part for date imputation. Here is the raw data below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Raw data:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data vy;&lt;BR /&gt;input id date $ 10.;&lt;BR /&gt;cards;&lt;BR /&gt;101 21aug2020&lt;BR /&gt;102 ukfeb2016&lt;BR /&gt;103 ukaug2019&lt;BR /&gt;104 ukunk2020&lt;BR /&gt;105 07aug2018&lt;BR /&gt;106 ukdec2020&lt;BR /&gt;107 ununkunkk&lt;BR /&gt;108 ukfeb2019&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;I need to do date imputation based on two points as below:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; 1.&amp;nbsp; If both month and day are missing, then set to December 31.&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;2. If only day is missing, then set to last day of the month.&lt;/P&gt;</description>
    <pubDate>Sun, 06 Aug 2023 05:10:19 GMT</pubDate>
    <dc:creator>112211</dc:creator>
    <dc:date>2023-08-06T05:10:19Z</dc:date>
    <item>
      <title>end date imputation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888045#M350868</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help in programming part for date imputation. Here is the raw data below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Raw data:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data vy;&lt;BR /&gt;input id date $ 10.;&lt;BR /&gt;cards;&lt;BR /&gt;101 21aug2020&lt;BR /&gt;102 ukfeb2016&lt;BR /&gt;103 ukaug2019&lt;BR /&gt;104 ukunk2020&lt;BR /&gt;105 07aug2018&lt;BR /&gt;106 ukdec2020&lt;BR /&gt;107 ununkunkk&lt;BR /&gt;108 ukfeb2019&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;I need to do date imputation based on two points as below:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; 1.&amp;nbsp; If both month and day are missing, then set to December 31.&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;2. If only day is missing, then set to last day of the month.&lt;/P&gt;</description>
      <pubDate>Sun, 06 Aug 2023 05:10:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888045#M350868</guid>
      <dc:creator>112211</dc:creator>
      <dc:date>2023-08-06T05:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: end date imputation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888848#M351149</link>
      <description>&lt;P&gt;data vy1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set vy;&lt;/P&gt;
&lt;P&gt;/*Seperate date into day, month, year */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; dayc=substr(date,1,2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; monthc=substr(date,3,3);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; yearc=substr(date,6,4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if yearc ne "unkk" then do; /*One row has year missing, not able to impute */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /*both month and day missing*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if dayc="uk" and monthc="unk" then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dayi="31";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; monthi="DEC";&lt;/P&gt;
&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /*only day missing*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if dayc="uk" and monthc ne"unk" then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myrc=cats(monthc)||cats(yearc);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myn=input(myrc, anydtdte7.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lastday=intnx('month',myn,0,'E');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; /*get imputed date*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if dayi ne "" and monthi ne "" then&lt;/P&gt;
&lt;P&gt;&amp;nbsp; date_impc=cats(dayi)||cats(monthi)||cats(yearc);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if lastday ne . then date_impc=put(lastday, date9.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; format date_imp date9.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; date_imp=input(date_impc, date9.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 19:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888848#M351149</guid>
      <dc:creator>Seadrago</dc:creator>
      <dc:date>2023-08-10T19:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: end date imputation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888851#M351152</link>
      <description>If month, day &amp;amp; year are missing( ID 107) does it follow Rule #1?</description>
      <pubDate>Thu, 10 Aug 2023 20:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888851#M351152</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-08-10T20:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: end date imputation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/889019#M351206</link>
      <description>I don’t believe so. ‘if yearc ne “unkk” then do;’ statement removes any year with missing from below logic</description>
      <pubDate>Sat, 12 Aug 2023 02:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/889019#M351206</guid>
      <dc:creator>Seadrago</dc:creator>
      <dc:date>2023-08-12T02:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: end date imputation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/889021#M351208</link>
      <description>All you really need to do is&lt;BR /&gt;&lt;BR /&gt;If the first character is not 'u' then it's a normal date9. string&lt;BR /&gt;else if the third character (where the month begins) is not 'u' then you only need to impute the leading '01'&lt;BR /&gt;else if the sixth character (where the year begins) is a number, then impute the leading '01dec'&lt;BR /&gt;otherwise the date value is set to missing&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;data vy;&lt;BR /&gt;input id date $ 10.;&lt;BR /&gt;cards;&lt;BR /&gt;101 21aug2020&lt;BR /&gt;102 ukfeb2016&lt;BR /&gt;103 ukaug2019&lt;BR /&gt;104 ukunk2020&lt;BR /&gt;105 07aug2018&lt;BR /&gt;106 ukdec2020&lt;BR /&gt;107 ununkunkk&lt;BR /&gt;108 ukfeb2019&lt;BR /&gt;;&lt;BR /&gt;data want;&lt;BR /&gt;  set vy;&lt;BR /&gt;  format datvalue date9.;&lt;BR /&gt;  if char(date,1) ^= 'u'         then datvalue=input(date,date9.);&lt;BR /&gt;  else if char(date,3)^='u'      then datvalue=input('01'||substr(date,3,7),date9.);&lt;BR /&gt;  else if '0'&amp;amp;lt;=char(date,6)&amp;amp;lt;='9' then datvalue=input('01dec'||substr(date,6),date9.);&lt;BR /&gt;run;&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;&amp;amp;nbsp;</description>
      <pubDate>Sat, 12 Aug 2023 13:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/889021#M351208</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-08-12T13:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: end date imputation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/889024#M351210</link>
      <description>&lt;P&gt;I already posted an answer to this in the thread that has been deleted in the meantime:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have (rename=(date=_date));
if substr(_date,6) = "unkk"
then date =.;
else do;
  if substr(_date,3,3) = "unk" then substr(_date,3,3) = "dec";
  if substr(_date,1,2) = "uk"
  then do;
    substr(_date,1,2) = "01";
    date = input(_date,date9.);
    date = intnx('month',date,0,'e');
  end;
  else date = input(_date,date9.);
end;
format date yymmdd10.; * always use the ISO format for clarity;
drop _date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Aug 2023 06:57:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/889024#M351210</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-08-12T06:57:21Z</dc:date>
    </item>
  </channel>
</rss>

