Table
| ID | date | no | what I want |
| … | |||
1 | 2000/11/1 | 2 | 由2000/8/2-2000/11/1 的no平方的累加 |
1 | 2000/11/2 | 3 | 由2000/8/3-2000/11/2 的no平方的累加 |
| … | |||
1 | 2000/11/31 | 4 | 由2000/9/1-2000/11/31 的no平方的累加 |
| … | |||
| … | |||
1 | 2001/2/1 | 3 | 由2000/11/2-2000/2/1 的no平方的累加 |
1 | 2001/2/2 | 6 | 由2000/11/3-2000/2/2 的no平方的累加 |
| … | |||
1 | 2001/2/28 | 7 | 由2000/12/1-2000/2/28 的no平方的累加 |
| … | |||
2 | 2005/11/1 | 2 | 由2005/8/2-2005/11/1 的no平方的累加 |
2 | 2005/11/2 | 3 | 由2005/8/3-2005/11/2 的no平方的累加 |
| … | |||
2 | 2005/11/31 | 4 | 由2005/9/1-2005/11/31 的no平方的累加 |
| … | |||
| … | |||
2 | 2006/2/1 | 3 | 由2005/11/2-2006/2/1 的no平方的累加 |
2 | 2006/2/2 | 6 | 由2005/11/3-2006/2/2 的no平方的累加 |
| … | |||
2 | 2006/2/28 | 7 | 由2005/12/1-2006/2/28 的no平方的累加 |
| … | |||
3 | |||
| … | |||
4 | |||
| … | |||
| … | |||
| … |
以下是我的代码,但很有问题。
proc sql;
create table result
as select distinct a.id, a.date, sum((b.no)^2) as cum_return
from table (keep=id date) as a, table as b
where a.id=b.id and 0<=intck('month', b.date, a.date)<3
group by a.id, a.date;
quit;
求高手指教,不一定要用SQL



雷达卡





京公网安备 11010802022788号







