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]作者: shiyiming 时间: 2008-10-8 17:55 标题: Re: 一个日期函数问题…… 谢谢你,
不过我只是想要一个函数,而不是算法
就像intnx('day','01feb2008',3)一样的函数,
SAS有解决我遇到问题的函数吗作者: shiyiming 时间: 2008-10-9 09:38 标题: Re: 一个日期函数问题…… 你已经知道答案只是你不会用而已,用intnx作者: shiyiming 时间: 2008-10-9 10:47 标题: Re: 一个日期函数问题…… 学习了。
a=intnx('month','06FEB2008'd,0,'E');