data sample_data;
infile datalines;
input original_variable $48.;
datalines;
20110503 09:58:47.65
;
run;
data modified_data;
set sample_data;
*** separate date from original string ***;
date=input(scan(original_variable,1,' '), yymmdd8.);
*** separate time from original string ***;
time=scan(original_variable,-1,' ');
*** separate out hours minutes and seconds ***;
hour=input(scan(time,1,':'),2.);
minute=input(scan(time,2,':'),2.);
second=input(scan(time,3,':'),2.);
*** create datetime variable ***;
datetime=dhms(date,hour,minute,second);
*** check work ***;
datetime2=put(datetime,datetime.);
run;
... View more