Reputation: 11
I have a sas dataset of some dates. I need to generate all dates from 01FEB2008 to 31AUG2009. How do i go about this? Also then i need to find all the missing dates from another column of dates. Please help
Upvotes: 0
Views: 5541
Reputation: 7769
Slightly more concise version of Honh Ooi's code...
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 ;
Upvotes: 4
Reputation: 57686
Untested:
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;
To find the missing dates:
data test;
merge dates (in=a) mydata (in=b);
by dte;
if a and not b;
run;
Upvotes: 0