SAS中文论坛

标题: a question about time() [打印本页]

作者: shiyiming    时间: 2012-8-2 22:40
标题: a question about time()
data _null_;
t=time();
format t datetime22.2;
put t=;
run;
run the code above, and I got the following result:
t=01JAN1960:09:42:30.38

Question: As we know time() function will generate the current time of day, but the result t is 01jan1960, so, anyone can help or explain?
thanks!!!
作者: shiyiming    时间: 2012-8-3 10:36
标题: Re: a question about time()
time()读的是时间的数据而没有读日期的数据,而datetime格式要求输出的是日期和时间,所以会出错
作者: shiyiming    时间: 2012-8-3 11:11
标题: Re: a question about time()
问题在于格式设置上,由于t=time(); 仅仅提取的是时间数据,而在格式的设置上却要求输出
日期,所以sas系统就加上了,系统默认的初始日期。请看下面的代码:
[code:28lbem29]
data _null_;
t1=time();
t2=t1;
format t1 time. t2 datetime22.2;
put t1= t2=;
run;
[/code:28lbem29]




欢迎光临 SAS中文论坛 (http://www.mysas.net/forum/) Powered by Discuz! X3.2