作者liton (欧吉桑留学生)
看板Statistics
标题Re: [程式] SAS资料计算
时间Sun Jun 27 16:12:06 2010
我程式的就两段
借用t大的资料
※ 引述《tew (咖啡王子)》之铭言:
: data a;
: input date date10. response;
: format date date9. ;
: cards;
: 09AUG07 1
: 23AUG07 1
: 06SEP07 2
: 20SEP07 2
: 05OCT07 3
: 16OCT07 3
: 30OCT07 3
: 29NOV07 1
: 01JAN08 2
: 10JAN08 3
: 19JAN08 3
: 30JAN08 4
: 10JUN08 4
: ;
: run;
data c;
set a;
retain initial_date group 0;
format initial_date date9. ;
if response ne 1 and response ne lag(response) then initial_date=date;
if response ne lag(response) then group+1;
tmp_days= date-initial_date+1 ;
run;
proc sql;
create table result as
select date,response,
(case when response eq 1 then 0 else max(tmp_days) end)
as days
from C
group by group ;
quit;
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.167.174.54
1F:→ liton:和t大的差异在01JAN2008这笔资料 06/27 16:12
2F:推 imaltar:受教了~~~ 06/27 17:39