-2

我有以下表格:

模型

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

尿路感染

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 中做到这一点?

4

1 回答 1

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

我不认识你的代码块。您正在使用某种伪代码,或者您正在使用我以前从未见过的高级 SAS 技术。把上面的东西和一粒盐一起吃。

于 2013-08-23T18:55:38.270 回答