try this:
data test1;
input d1 yymmdd8. +1 d2 yymmdd8.;
format d1 mmddyy10.
d2 mmddyy10.
;
cards;
20050429 20050322
20050430 20070331
20070403 20050201
20050325 20050223
20050427 20050425
20050510 20050423
;
run;
data resultt(drop=dd1);
if 0 then set test1 nobs=nn;
set test1;
do i=1 to nn;
set test1(keep=d1 rename=(d1=dd1)) point=i;
if d2<dd1<d1 then count+1;
end;
output;
count=0;
run;