SAS可以存儲和使用包含小於1/10秒的分數的日期時間嗎?SAS信息日期時間毫秒
例如:
data _null_;
input @1 from_dt:datetime22.;
put from_dt= ;
cards;
24Sep2009:11:21:19.856
;
run;
SAS可以存儲和使用包含小於1/10秒的分數的日期時間嗎?SAS信息日期時間毫秒
例如:
data _null_;
input @1 from_dt:datetime22.;
put from_dt= ;
cards;
24Sep2009:11:21:19.856
;
run;
日期時間變量就像任何其他數字變量一樣是一個數字變量。我們只是將它的價值理解爲自01jan1960T00:00:00以來的秒數。希望這可以幫助。
data _null_;
/* for date time, 1 means 1 sec since midnight jan 1st 1960 */
dt = 1;
put dt :datetime.;
/* you can show the hundredth of second using datetime format */
dt = 0.01;
put dt :datetime19.2;
/* but it is just a double type number. you can do
what you want with the variable as with any other numeric
variables */
dt = 0.01;
put "It was " dt :wordf15. "second after midnight.";
run;
/* on log
01JAN60:00:00:01
01JAN60:00:00:00.01
it was zero and 01/100 second after midnight.
*/
你的示例代碼是在打印輸出的舍入。在PUT語句添加格式(例如best32)表明,有更好的精確度正在舉行...
data _null_;
input @1 from_dt:datetime22.;
put from_dt= best32.;
cards;
24Sep2009:11:21:19.856
;
run;
from_dt=1569410479.856
正如羅格指出的那樣,你可以閱讀和存儲日期時間比0.1秒更精確。
只需使用datetime22.3或類似的格式和信息而不是datetime22。