Study SAS

統計解析ソフトウェアSASについて学習したことのまとめやSAS認定試験対策など

SAS Base Programmer 練習問題24

以下の内容のSASデータセットWORK.TESTがある。

capacity airplanetype staff
150 Large 10

このデータセットを出力するSASプログラムは以下のどれか

A.

data work.test
    capacity = 150;
    if 100 le capacity le 200 then
        airplanetype = 'Large' and staff = 10;
    else
        airplanetype = 'Small' and staff = 5;
run;

B.

data work.test;
    capacity = 150;
    if 100 le capacity le 200 then do;
        airplanetype = 'Large';
        staff= 10;
    end;
    else do; 
        airplanetype = 'Small';
        staff = 5;
    end;
run;

C.

data work.test;
    capacity = 150;
    if 100 le capacity le 200 then do;
        airplanetype = 'Large';
        staff = 10;
    else do;
        airplanetype = 'Small';
        staff = 5;
    end;
run;

D.

data work.test;D.data work.test;
    capacity = 150;
    if 100 le capacity le 200 then;
        airplanetype = 'Small';
        staff = 5;
    else;
        airplanetype = 'Large';
        staff = 10;
run;

出典はこちら


答え: B (要反転)

B以外はシンタックスエラーとなる。IF-ELSEブロック内で複数のステートメントを実行する場合はDO-ENDで括る必要がある。