In SAS, fields are either character of varying length, or numeric. No exceptions. Temporal values such as Date and Date/Time are stored as either the number of days or seconds since 1960 January 1st.

In order to convert from Date/Time to Date, and from Date to Date/Time, you could divide or multiply respectively by 86400 (the number of seconds in a day).

data _null_;
d='29FEB1984'd;
put d date.;
<strong>dt=d*24*60*60;</strong>
put dt datetime.;
<strong>d=dt/24/60/60;</strong>
put d date.;
run;

But unless someone deals with dates every day, it might not be obvious to them by reading this code what those magic numbers are doing.

Another method would be to use put() and input() using functions to go back and fourth.

data _null_;
d='29FEB1984'd;
put d date.;
<strong>dt=input(put( d  ,date7.) || ':00:00:00', datetime.);</strong>
put dt datetime.;
<strong>d =input(substr(put(dt,datetime.),1,7),date7.);</strong>
put d date.;
run;

But I don't consider this any better. It's wordy. Functions are nested within functions. And you still have a magic number for the call to substr. Also, since it isn't uncommon for SAS datasets to get into the billions of rows, this probably isn't the fastest way to do it.

SAS has built-in functions called dhms() (mnemonic: date,hour,minute,second) and datepart() that should make things a lot easier.

data _null_;
d='29FEB1984'd;
put d date.;
<strong>dt=dhms(d,0,0,0);</strong>
put dt datetime.;
<strong>d =datepart(dt);</strong>
put d date.;
run;