|
8#
楼主 |
发表于 2003-10-7 18:23:50
|
只看该作者
回复:
libname test 'j:\test' ;
data test1;
informat MAXJH YYMMDD10. MAXSS YYMMDD10.;
format MAXJH YYMMDD10. MAXSS YYMMDD10.;
set test.gao;
d1=MAXSS-MAXJH;
d2=intck('day',MAXJH,MAXSS);
run;
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;
OUTPUT:
FIRST_
Obs MAXJH MAXSS SERIAL_NO IMPR d1 d2
1 2999-01-01 2002-11-16 1000000016 08/01/96 -363828 -363828
2 2999-01-01 2999-01-01 1000000017 01/01/96 0 0
3 2999-01-01 2999-01-01 1000000020 08/01/96 0 0
4 2999-01-01 2999-01-01 1000000021 08/01/96 0 0
5 2999-01-01 2999-01-01 1000000022 08/01/96 0 0
6 2999-01-01 2999-01-01 1000000023 08/01/96 0 0
7 2999-01-01 2999-01-01 1000000025 08/01/96 0 0
8 2999-01-01 2999-01-01 1000000026 08/01/96 0 0
9 2999-01-01 2999-01-01 1000000027 08/01/96 0 0
10 2003-02-17 2003-08-18 1000000036 08/01/93 182 182
从以上结果可看出你的原始数据集好象有问题.
FIRST_
Obs MAXJH MAXSS SERIAL_NO IMPR d1 d2
1 1999-01-01 2002-11-16 1000000016 08/01/96 1415 1415
2 1999-01-01 1999-01-01 1000000017 01/01/96 0 0
3 1999-01-01 1999-01-01 1000000020 08/01/96 0 0
4 1999-01-01 1999-01-01 1000000021 08/01/96 0 0
5 1999-01-01 1999-01-01 1000000022 08/01/96 0 0
6 1999-01-01 1999-01-01 1000000023 08/01/96 0 0
7 1999-01-01 1999-01-01 1000000025 08/01/96 0 0
8 1999-01-01 1999-01-01 1000000026 08/01/96 0 0
9 1999-01-01 1999-01-01 1000000027 08/01/96 0 0
10 2003-02-17 2003-08-18 1000000036 08/01/93 182 182
比较笨的办法 <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D --> 抛砖引玉而已 |
|