<?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: Create imputation flag for missing month and day in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818811#M323225</link>
    <description>Sorry about that! When month and day are missing, I impute January 1st</description>
    <pubDate>Fri, 17 Jun 2022 12:55:00 GMT</pubDate>
    <dc:creator>westbestern</dc:creator>
    <dc:date>2022-06-17T12:55:00Z</dc:date>
    <item>
      <title>Create imputation flag for missing month and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818723#M323177</link>
      <description>&lt;P&gt;I'm working on coding SDTM to ADaM and I want to create an imputation flag "M" when both month and day are missing (ex: 2014 instead of 2014-06-18) and create a new variable called DTHDT (date of death). I have an example below of what I did for a missing day. How do I go about doing this for a missing month and day?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* if day is missing in dthdtc then do */&lt;BR /&gt;if length(dthdtc)=7 then do;&lt;BR /&gt;dthdt= input(strip(dthdtc) || '-01', yymmdd10.); *concatenating '-01' to the end of the character &lt;BR /&gt;date string and converting to numeric;&lt;BR /&gt;dthdtf='D'; *flag is 'D' when day is imputed;&lt;BR /&gt;end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Jun 2022 21:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818723#M323177</guid>
      <dc:creator>westbestern</dc:creator>
      <dc:date>2022-06-16T21:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: Create imputation flag for missing month and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818727#M323180</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* if day is missing in dthdtc then do */
if length(dthdtc)=7 then do;
         dthdt= input(strip(dthdtc) || '-01', yymmdd10.); 
       *concatenating '-01' to the end of the character date string and converting to numeric;
          dthdtf='D'; 
          *flag is 'D' when day is imputed;
end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Similarly?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* if month&amp;amp;  day is missing in dthdtc then do */
if length(dthdtc)=4 then do;
         dthdt= input(strip(dthdtc) || '07-15', yymmdd10.); 
       *concatenating '07-15' to the end of the character date string and converting to numeric;
          dthdtmnthf='D'; 
          *flag is 'D' when month day is imputed;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Why did you impute day as 1?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Typically for date imputations I've seen the 15th and July used as cutoffs for population/research statistics. It has something to do with allowing it to balance out over time but I suspect it's not too important.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/400922"&gt;@westbestern&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm working on coding SDTM to ADaM and I want to create an imputation flag "M" when both month and day are missing (ex: 2014 instead of 2014-06-18) and create a new variable called DTHDT (date of death). I have an example below of what I did for a missing day. How do I go about doing this for a missing month and day?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* if day is missing in dthdtc then do */&lt;BR /&gt;if length(dthdtc)=7 then do;&lt;BR /&gt;dthdt= input(strip(dthdtc) || '-01', yymmdd10.); *concatenating '-01' to the end of the character &lt;BR /&gt;date string and converting to numeric;&lt;BR /&gt;dthdtf='D'; *flag is 'D' when day is imputed;&lt;BR /&gt;end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 22:08:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818727#M323180</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-16T22:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create imputation flag for missing month and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818802#M323220</link>
      <description>&lt;P&gt;I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/400922"&gt;@westbestern&lt;/a&gt;&amp;nbsp;meant the flag is dthdtf='M' when month is imputed.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 12:21:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818802#M323220</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-17T12:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: Create imputation flag for missing month and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818805#M323222</link>
      <description>&lt;P&gt;what are you imputing month and day to when both are missing? show us the imputation rules.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 12:23:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818805#M323222</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-17T12:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create imputation flag for missing month and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818806#M323223</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input dthdtc :$18.;
datalines;
2014
2014-06
2014-06-18
;
run;

data want;
	set have;
	format dthdt yymmdd10.;
	year=scan(dthdtc,1,'-');
	day=scan(dthdtc,3,'-');
	mth=scan(dthdtc,2,'-');
	if nmiss(year,day,mth)=0 then dthdt=input(catx('-',year,mth,day),yymmdd10.);
	*only day missing;
	if day='' and mth ne '' then do;
		day='01';
		dthdtf='D';
		dthdt=input(catx('-',year,mth,day),yymmdd10.);
	end;
	*day and month both missing;
	if day='' and mth='' then do;
		day='01';
		mth='01';
		dthdtf='M';
		dthdt=input(catx('-',year,mth,day),yymmdd10.);
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you didn't tell us the imputation rules. I imputed day to '01' when it's missing and imputed both day and month to '01' when both are missing.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 12:34:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818806#M323223</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-17T12:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create imputation flag for missing month and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818811#M323225</link>
      <description>Sorry about that! When month and day are missing, I impute January 1st</description>
      <pubDate>Fri, 17 Jun 2022 12:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818811#M323225</guid>
      <dc:creator>westbestern</dc:creator>
      <dc:date>2022-06-17T12:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create imputation flag for missing month and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818813#M323226</link>
      <description>&lt;P&gt;Okay, that's the way I did it in the code I gave you. Please test it out and feel free to accept as solution if it works for you.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 12:56:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-imputation-flag-for-missing-month-and-day/m-p/818813#M323226</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-17T12:56:17Z</dc:date>
    </item>
  </channel>
</rss>

