<?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: end date imputation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888048#M350871</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have (rename=(date=_date));
if upcase(substr(_date,6)) = "UNKK"
then date = .;
else do;
  if upcase(substr(_date,3,3)) = "UNK"
  then substr(_date,3,3) = "DEC";
  if upcase(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.;
drop _date;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested, posted from my tablet.&lt;/P&gt;</description>
    <pubDate>Sun, 06 Aug 2023 07:09:14 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-08-06T07:09:14Z</dc:date>
    <item>
      <title>end date imputation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888047#M350870</link>
      <description>&lt;P&gt;Hi Team,&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;&lt;P&gt;I need help in programming part for date imputation. Here is the raw data below attachement&lt;/P&gt;</description>
      <pubDate>Sun, 06 Aug 2023 06:16:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888047#M350870</guid>
      <dc:creator>190119</dc:creator>
      <dc:date>2023-08-06T06:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: end date imputation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888048#M350871</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have (rename=(date=_date));
if upcase(substr(_date,6)) = "UNKK"
then date = .;
else do;
  if upcase(substr(_date,3,3)) = "UNK"
  then substr(_date,3,3) = "DEC";
  if upcase(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.;
drop _date;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested, posted from my tablet.&lt;/P&gt;</description>
      <pubDate>Sun, 06 Aug 2023 07:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888048#M350871</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-08-06T07:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: end date imputation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888049#M350872</link>
      <description>&lt;P&gt;Please do not use attachments for code. Copy/paste the code into a window opened with the "little running man" button. That way we can immediately see and use the code (e.g. copy/paste into SAS Studio) without having to download first.&lt;/P&gt;</description>
      <pubDate>Sun, 06 Aug 2023 07:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888049#M350872</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-08-06T07:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: end date imputation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888068#M350877</link>
      <description>&lt;P&gt;Here's the attached code:&lt;/P&gt;
&lt;PRE&gt;data vy;
input id date  $  10.;
cards;
101 21aug2020
102 ukfeb2016
103 ukaug2019
104 ukunk2020
105 07aug2018
106 ukdec2020
107 ununkunkk
108 ukfeb2019
;&lt;/PRE&gt;
&lt;P&gt;The real question in my mind is the un unk and unkk. Where did they come from? Someone made them. Perhaps address that so that you get values like&lt;/P&gt;
&lt;PRE&gt;101 21aug2020
102 feb2016
103 aug2019
104 2020
105 07aug2018
106 dec2020
107 .
108 feb2019
;&lt;/PRE&gt;
&lt;P&gt;Testing the length of the variable would then allow selecting the proper handling...&lt;/P&gt;</description>
      <pubDate>Sun, 06 Aug 2023 15:19:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888068#M350877</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-06T15:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: end date imputation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888071#M350879</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  if date='ununkunkk'   then sasdate=.;
  else if date=:'ukunk' then sasdate=input(cats('31dec',substr(date,6,4)),date9.);
  else if date=:'uk'    then sasdate=intnx('month',input(substr(date,3,7),monyy7.),0,'end');
  else sasdate=input(date,date9.);
  format sasdate date9.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You did provide your sample data inside a working data step - thanks.&amp;nbsp; BUT ...&lt;/P&gt;
&lt;P&gt;Please make it viewable by using the insert code icon ("running man") rather than as an attachment.&lt;/P&gt;</description>
      <pubDate>Sun, 06 Aug 2023 16:37:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/end-date-imputation/m-p/888071#M350879</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-08-06T16:37:47Z</dc:date>
    </item>
  </channel>
</rss>

