使用“scan”函数。
下面是你的数据的一个例子。注意下面的这个数据中只有一个空格,在“9点”以前。
data A;
input date_time $20.;
datalines;
2003-12-1 9:24:25
;
run;
data A;
set A;
date=scan(date_time,1,' ');
time=scan£¨date_time,2,' ');
year=scan(date,1,'-');
month=scan(date,2,'-');
day=scan(date,3,'-');
hour=scan(time,1,':');
minute=scan(time,2,':');
second=scan(time,3,':');
real_date=mdy(month, day,year);
real_date_time=dhms(real_date,hour,minute,second);
run;
data A;
set A;
format real_date_time datetime.;
run;
quit;