我有以下表格:
模型表
Model State FH
NEW-20 1 279
NEW-20 2 279
NEW-20 3 204
NEW-20 4 186
NEW-21 1 333
SA 表
Driver Year Scenario;
GDP 2013 Nominal
Fuel 2013 Nominal
Mili 2013 Nominal
GDP 2014 Nominal
Fuel 2014 Nominal
Mili 2014 Nominal
GDP 2015 Nominal
Fuel 2015 Nominal
UTI 表
Driver Scenario State var1 var2 var3 var4 var5 var6;
GDP Nominal 1 0.0% 0.0% 0.0% 0.0% 0.0% 0.0%
GDP Strong_G 2 10.0% 12.0% 7.5% 10.0% 10.0% 0.0%
GDP Mild_D 4 -5.0% -8.0% -4.0% -10.0% -8.0% -2.5%
Mil Strong_D 1 -6.0% -10.0% -6.0% -12.0% -10.0% -5.0%
MIL Nominal 1 0.0% 0.0% 0.0% 0.0% 0.0% 0.0%
我想使用条件IF语句。什么是正确的语法?以下是我想要做的事情:
(IF Model.State & SA.Driver (GDP) & SA.Scenario = UTI.Driver & UTI.Scenario & UTI.State
THEN SUMPRODUCT((1+(UTI.VAR1--VAR6));MODEL.FH)
+
IF Model.State & SA.Driver(Fuel) & SA.Scenario = UTI.Driver & UTI.Scenario & UTI.State
THEN SUMPRODUCT((1+(UTI.VAR1--VAR6));MODEL.FH)
+
IF Model.State & SA.Driver(Mil) & SA.Scenario = UTI.Driver & UTI.Scenario & UTI.State
THEN SUMPRODUCT((1+(UTI.VAR1--VAR6));MODEL.FH))
AS TOTAL
我如何在SAS中完成?
答案 0 :(得分:0)
您似乎正在尝试使用PROC SQL
?
如果是,那么您正在寻找CASE
声明:
(CASE WHEN Model.State & SA.Driver (GDP) & SA.Scenario = UTI.Driver & UTI.Scenario & UTI.State
THEN SUMPRODUCT((1+(UTI.VAR1--VAR6));MODEL.FH) ELSE 0 /* <- Insert else case here */ END
+
CASE WHEN Model.State & SA.Driver(Fuel) & SA.Scenario = UTI.Driver & UTI.Scenario & UTI.State
THEN SUMPRODUCT((1+(UTI.VAR1--VAR6));MODEL.FH) ELSE 0 /* <- Insert else case here */
+
CASE WHEN Model.State & SA.Driver(Mil) & SA.Scenario = UTI.Driver & UTI.Scenario & UTI.State
THEN SUMPRODUCT((1+(UTI.VAR1--VAR6));MODEL.FH) ELSE 0 /* <- Insert else case here */ END)
AS TOTAL
我不认识你的代码块。你要么使用某种pseduo代码,要么使用我以前从未见过的高级SAS技术。带上一粒盐就可以了。