我想通过使用条件创建 2012 到 2022 的 Age 变量,我可以使用 YEAR(calculated td-1), YEAR(calculated td), YEAR(calculated td+1),YEAR(calculated td) 来一一完成+2)但这是一个漫长的过程。表2中有年份是重复的。请帮助我一步完成。
这是示例代码:
proc sql;
create table Forecast1(DROP=td) as
select T1.*
,date() as td
,case
when (YEAR(calculated td))- year(T1.Engine)<=10 then '0-10'
when (YEAR(calculated td))- year(T1.Engine)<=20 then '10-20'
when (YEAR(calculated td))- year(T1.Engine)<=35 then '20-35'
else '35p' end as Age_2013 format=$char5.
from gopi1.FLEET_MASTER T1
left join gopi1.ANNUAL_FH_AVERAGE T2
on T1.Model=T2.Model and T1.Age_bracket=T2.Age_bracket