|
|
板凳

楼主 |
发表于 2008-10-8 16:19:11
|
只看该作者
Re: 一个日期函数问题……
[code:m6xh0k0y]data aa;
input date $10.;
cards;
2008-01-06
2008-02-01
2008-03-05
2008-04-10
2008-05-12
2008-06-08
2008-07-17
2008-08-02
2008-09-03
2008-10-10
2008-11-21
2008-12-22
;
run;
data temp;
set aa;
date1=input(date,yymmdd10.);
year=year(date1);
month=month(date1);
if month in (1,3,5,7,8,10,12) then last=trim(left(year))||"-"||trim(left(put(month,z2.)))||"-31";
else if month in (4,6,9,11) then last=trim(left(year))||"-"||trim(left(put(month,z2.)))||"-30";
else if mod(year,4)=0 then do;
if mod(year,100)=0 and mod(year,400) ne 0 then
last=trim(left(year))||"-"||trim(left(put(month,z2.)))||"-28";
else last=trim(left(year))||"-"||trim(left(put(month,z2.)))||"-29";
end;
else last=trim(left(year))||"-"||trim(left(put(month,z2.)))||"-28";
run;[/code:m6xh0k0y] |
|