data _null_;
input @1 x ddmmyy6. @8 y ddmmyy6.;
days=y-x;
put x=;
put y=;
put days=;
datalines;
010199 010102
;
run;
输出结果(log窗口)如下:
x=14245
y=15341
days=1096作者: shiyiming 时间: 2003-10-3 10:02
Your SAS was confused by 1/1/02, becasue it dose not know your date is 1/1/2002 or 1/1/1902. You can use yearcutoff option to tells SAS how to explain your two digits year.
"Yearcutoff=" specifies the first year of a hundred-year span for SAS to use.
So you can write the following option before your program.
options yearcutoff=1950;
It tells SAS all your dates will be between 1950 and 2049.作者: shiyiming 时间: 2003-10-3 13:11
我再回去试一试吧
不过我记得好像SAS系统不是默认1960的么
也就是说百年指1960-2059的呀
我也记得不是太清楚了
实在不行就多加个回合
反正都是本世纪前后的数据作者: shiyiming 时间: 2003-10-3 14:21 标题: Re: ask for help [quote="阿P":bd7b9]请教各位大侠:
sas里面的日期差计算怎么办
好像用减法或是intck可以的
但对于跨千年的时间好像结果有问题啊
比如1/1/99与1/1/02的时间差系统计算出的不对啊
怎么个设置法或是还有别的其他方法?
谢谢![/quote:bd7b9]
data test;
t1='1jan98'd;
t2='1jan03'd;
t3=t2-t1;
t4=intck('day',t1,t2);
;
proc print;run;
/*Then you will find the error. But how to correct it?*/
data test2;
informat MAXJH YYMMDD10. MAXSS YYMMDD10.;
format MAXJH YYMMDD10. MAXSS YYMMDD10.;
set test.gao;
if year(MAXJH)>2900 then MAXJH=MDY(month(MAXJH),day(MAXJH),(year(MAXJH)-1000));
if year(MAXSS)>2900 then MAXSS=MDY(month(MAXSS),day(MAXSS),(year(MAXSS)-1000));
d1=MAXSS-MAXJH;
d2=intck('day',MAXJH,MAXSS);
run;
proc print;run;