|
7#

楼主 |
发表于 2011-4-15 06:33:42
|
只看该作者
Re: 请问如何计数?
I did not know anyone check the result or not.
I run the solution code above, and found some problems, e.g. obveriously, only 1 record within 20050203--20050104, but the result is 2.
my solution is:
[code:l94vzml6]data a;
input date1 yymmdd8. date2 yymmdd10.;
format date1 date2 date9.;
unid=catx('_',date1,date2);
cards;
20050203 2005-1-4
20050303 2005-2-1
20050325 2005-2-23
20050412 2005-3-13
20050418 2005-3-19
20050427 2005-3-28
20050509 2005-4-9
20050510 2005-4-10
20050518 2005-4-18
20050523 2005-4-23
20050526 2005-4-26
20050531 2005-5-1
20050603 2005-5-4
20050606 2005-5-7
20050607 2005-5-8
20060619 2006-5-20
20060623 2006-5-24
20060627 2006-5-28
20060627 2006-5-28
;
run;
proc sql;
create table b as
select distinct unid,count(distinct date1) as cnt
from (select d1.unid,d2.date1
from a d1,a d2
where d1.date2<=d2.date1<=d1.date1)
group by unid
order by unid;
quit;[/code:l94vzml6] |
|