Convert char DATETIME to SAS date
<p>I have some de-identified EHR data that includes a contact date for each physician encounter. These large files are .txt and imported as such:</p>

<pre><code>PROC IMPORT OUT = WORK.DM1
DATAFILE="T:\DM_DEID\PAT_ENC_DX.txt"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;
</code></pre>

<p>The Contact_Date variable, however is imported as a char type, with informat $21. (see attached image). I have looked a several methods to convert this to a date, without the meaningless timestamp, but nothing has worked yet. The below code has gotten me close, except it only captures the first number of the 'days' and leaves some cells blank (see image 2)
<a href="https://i.stack.imgur.com/dFFMv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dFFMv.png" alt="enter image description here"></a></p>

<pre><code>DATA DM1_;
SET DMI;
DATE=INPUT(SUBSTR(CONTACT_DATE,4,10),YYMMDD.);
FORMAT DATE MMDDYYD10.;
RUN;
</code></pre>

<p><a href="https://i.stack.imgur.com/SgGEF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SgGEF.png" alt="enter image description here"></a></p>

<p>I get the following error, which Im finding hard to decipher: "Invalid argument to function INPUT at line 66, column6."</p>

<p>Any help would be greatly appreciated. I can also supply more information if needed. Thanks.</p>