我有一些日期的sas数据集。我需要生成从01FEB2008到31AUG2009的所有日期。我该怎么做?此外,我需要从另一列日期中找到所有缺少的日期。请帮忙
答案 0 :(得分:4)
Honh Ooi的代码稍微简洁一点......
data alldates ; do dt = '01feb2008'd to '31aug2009'd ; output ; end ; format dt date9. ; run ; proc sql ; create table dtmiss as select * from alldates where dt not in(select dt from mydata) ; quit ;
答案 1 :(得分:0)
未测试:
data dates (keep=dte);
start = '01feb2008'd;
end = '31aug2009'd;
len = end - start;
format dte date9.;
do i = 0 to len;
dte = start + i;
output;
end;
run;
找到缺少的日期:
data test;
merge dates (in=a) mydata (in=b);
by dte;
if a and not b;
run;