Thank you, Reeze. Log file already overwritten.
I ended up with 2 steps, first step select the 30 days data and second step to do the summaries.
proc sql;
create table test.first30days as
select *
from anawager.dupi_wager_b_all
group by DUPI
having datepart(wagerdatetime) <= min(datepart(wagerdatetime))+30;
quit;
proc sql;
create table test.first30days_stat as
select DUPI,
count(distinct provider) as sites_wagered,
count(distinct datepart(wagerdatetime) ) as betting_days,
min(total_wager) as min_wager,
max(total_wager) as max_wager,
mean(total_wager) as mean_wager,
std(total_wager) as std_wager,
sum(total_wager) as sum_wager,
count(total_wager) as count_wager
from test.first30days
where total_wager>0 /* some total_wager<0; so many =0 */
group by DUPI;
quit;
... View more