目錄
- 1.日期格式
- 2.缺失日期的比較
- tod. 時間不完整填補
- 缺失自動填補最早日期
點擊跳轉函式跳轉使用例子
tod.時間補全函式
anydtdtm.缺失日期讀入函式
anydtdte.缺失自動填補最早日期
1.日期格式
2.缺失日期的比較
anydtdtm.函式
data b;
a1 = "2011-01-15T12:55:00"; **完整e8601格式,可以識別;
a2 = input(a1,anydtdtm.);
b1 = "2011-01-15"; /*只有日期,可以識別*/
b2 = input(b1,anydtdtm.);
c1 = "2011-01";
c2 = input(c1,anydtdtm.); /*只有年月,可以識別*/
d1 = "2011";
d2 = input(d1,anydtdtm.); /*只有年份無法讀入,使用 anydtdte. 自動補齊最早日期后再讀入*/
e1 = "2011-01-15T12:55"; /*時間格式不完整,無法讀入,使用tod.函式或time8.函式進行補0變為標準時間*/
e2 = input(e1,anydtdtm.);
f1 = "2011/01/15"; /*日期之間是斜桿,也可以識別*/
f2 = input(f1,anydtdtm.);
g1 = "2011-01-15 12:55:00"; /*時間日期沒有T可以識別*/
g2 = input(g1,anydtdtm.);
run;
tod. 時間不完整填補
tod.函式
轉換時間一般用的 time8. 但是HH小于10,前面不會補0,用tod8. 可以補齊前后的0
data t;
input tim $;
cards;
2:22
12:12:55
21:13
2:13
;
run;
data t2;
set t;
tim2=input(tim,time8.);
format tim2 time8.;
run;
data t3;
set t2;
tim3_Tod=put(tim2,tod8.); **用tod8.函式;
tim4_Time=put(tim2,time8.);
run;

缺失自動填補最早日期
anydtdte.函式
data test;
a="2021-08";
b=input(a,anydtdte.);
format b yymmdd10.;
run;
本文來自博客園,作者:Zain·Wilson,轉載請注明原文鏈接:https://www.cnblogs.com/ZainWilson/p/16875273.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/531444.html
標籤:其他
下一篇:淺談PHP設計模式的原型模式
