连续两个月购买的人叫'repeat',上个月没买过这个月买叫'new',上个月买过这个月没买叫'lapsed',这边的code是我写的季度的,如果想看每个月的,怎么能简化,不用一个一个跑,
谢谢各位大侠
data a(keep=store customerid type id);
set sales;
if customerid ne 'NULL' and '01oct2009'd<=purchasetime<='31mar2010'd;
if '01oct2009'd<=purchasetime<='31dec2009'd then type='old';
if '01jan2010'd<=purchasetime<='31mar2010'd then type='new';
id=customerid||type;
run;
proc sort data=a nodupkey;by id;run;
data b;
set a;
by customerid;
format new $20. old $20.;
retain new old;
if first.customerid then do;
new='';old='';end;
if type='new' then new='Y';
if type='old' then old='Y';
if last.customerid then output;
run;
data bb;
set b;
format customertype $20.;
if new='Y' and old='Y' then customertype='repeat';
if new='Y' and old='' then customertype='new';
if new='' and old='Y' then customertype='lapsed';
run;
proc sql;
create table c as
select customertype,count(*)as n from bb
group by 1
order by 1;
quit;