原始数据
- temperature.csv
province | year | month | temperature |
安徽 | 1996 | 1 | 3 |
安徽 | 1996 | 2 | 3.8 |
安徽 | 1996 | 3 | 8.1 |
安徽 | 1996 | 4 | 15.2 |
安徽 | 1996 | 5 | 21.3 |
安徽 | 1996 | 6 | 24.9 |
安徽 | 1996 | 7 | 27.3 |
安徽 | 1996 | 8 | 27.9 |
安徽 | 1996 | 9 | 23.9 |
安徽 | 1996 | 10 | 17.7 |
安徽 | 1996 | 11 | 9.9 |
安徽 | 1996 | 12 | 6.4 |
安徽 | 1997 | 1 | 2.8 |
安徽 | 1997 | 2 | 5.4 |
安徽 | 1997 | 3 | 11.2 |
安徽 | 1997 | 4 | 16.4 |
安徽 | 1997 | 5 | 24 |
安徽 | 1997 | 6 | 26.5 |
安徽 | 1997 | 7 | 28 |
安徽 | 1997 | 8 | 28.5 |
安徽 | 1997 | 9 | 22.5 |
安徽 | 1997 | 10 | 19 |
安徽 | 1997 | 11 | 10.6 |
安徽 | 1997 | 12 | 5.9 |
我是这么写的,但是不行
proc sql;create table tmp1 as select distinct
province,year,
mean(temperature) as temperature_avgyear,
case when year in (6,7,8) then mean(temperature) else . end as temperature_avgwinter
from
temperature
group by province,year;
quit;