/* Lesson 10-1 */
 /*    File Name = les1001.sas   06/20/02   */
data gakusei;                                 :
  infile 'all02.prn' firstobs=2;              : 2行目からをデータとして読み込む
  input sex $ height weight chest             :
        jitaku $ kodukai carrier $ tsuuwa;    :
                                              :
proc print data=gakusei(obs=10);              : きちんと読み込めたか確認のため
run;                                          :
                                              :
proc freq data=gakusei;                       : 頻度を算出
  tables sex jitaku carrier;                  : 一変量ごとに
run;                                          :
proc freq data=gakusei;                       : 頻度を算出
  tables sex*jitaku;                          : 二変量の組み合わせで
  tables sex*carrier;                         :
  tables jitaku*carrier;                      :
run;                                          :
                              SAS システム                             1
                                           11:29 Thursday, June 13, 2002
   OBS  SEX  HEIGHT  WEIGHT  CHEST  JITAKU  KODUKAI  CARRIER  TSUUWA
     1   F    145.0   38.0      .     J       10000               . 
     2   F    148.0   42.0      .     J       50000               . 
     3   F    148.0   43.0     80     J       50000  DoCoMo    4000 
     4   F    148.9     .       .     J       60000               . 
     5   F    149.0   45.0      .     G       60000               . 
     6   F    150.0   46.0     86             40000               . 
     7   F    151.7   41.5     80     J       35000               . 
     8   F    152.0   35.0     77     J       60000  DoCoMo    2000 
     9   F    153.0   41.0      .     J      125000  No           . 
    10   F    153.0   46.5     87     G       10000               . 
                              SAS システム                             2
                                           11:15 Thursday, June 13, 2002
                                      Cumulative  Cumulative
           SEX   Frequency   Percent   Frequency    Percent 
           -------------------------------------------------
           F           76      31.7          76       31.7  
           M          164      68.3         240      100.0  
                         Frequency Missing = 3
                                        Cumulative  Cumulative
          JITAKU   Frequency   Percent   Frequency    Percent 
          ----------------------------------------------------
          G              76      35.5          76       35.5  
          J             138      64.5         214      100.0  
                         Frequency Missing = 29
                                        Cumulative  Cumulative
         CARRIER   Frequency   Percent   Frequency    Percent 
         -----------------------------------------------------
         DDIp             1       3.4           1        3.4  
         DoCoMo          14      48.3          15       51.7  
         J-PHONE          7      24.1          22       75.9  
         No               3      10.3          25       86.2  
         au               4      13.8          29      100.0  
                        Frequency Missing = 214
                              SAS システム                             4
                                           11:15 Thursday, June 13, 2002
                         TABLE OF SEX BY JITAKU
                  SEX       JITAKU
                  Frequency|
                  Percent  |
                  Row Pct  |
                  Col Pct  |G       |J       |  Total
                  ---------+--------+--------+
                  F        |     20 |     48 |     68
                           |   9.43 |  22.64 |  32.08
                           |  29.41 |  70.59 |
                           |  26.67 |  35.04 |
                  ---------+--------+--------+
                  M        |     55 |     89 |    144
                           |  25.94 |  41.98 |  67.92
                           |  38.19 |  61.81 |
                           |  73.33 |  64.96 |
                  ---------+--------+--------+
                  Total          75      137      212
                              35.38    64.62   100.00
                  Frequency Missing = 31
                              SAS システム                             7
                                           11:15 Thursday, June 13, 2002
                        TABLE OF SEX BY CARRIER
     SEX       CARRIER
     Frequency|
     Percent  |
     Row Pct  |
     Col Pct  |DDIp    |DoCoMo  |J-PHONE |No      |au      |  Total
     ---------+--------+--------+--------+--------+--------+
     F        |      0 |      7 |      3 |      1 |      2 |     13
              |   0.00 |  25.00 |  10.71 |   3.57 |   7.14 |  46.43
              |   0.00 |  53.85 |  23.08 |   7.69 |  15.38 |
              |   0.00 |  50.00 |  50.00 |  33.33 |  50.00 |
     ---------+--------+--------+--------+--------+--------+
     M        |      1 |      7 |      3 |      2 |      2 |     15
              |   3.57 |  25.00 |  10.71 |   7.14 |   7.14 |  53.57
              |   6.67 |  46.67 |  20.00 |  13.33 |  13.33 |
              | 100.00 |  50.00 |  50.00 |  66.67 |  50.00 |
     ---------+--------+--------+--------+--------+--------+
     Total           1       14        6        3        4       28
                  3.57    50.00    21.43    10.71    14.29   100.00
     Frequency Missing = 215
 /* Lesson 10-2 */
 /*    File Name = les1002.sas   06/20/02   */
data gakusei;
  infile 'all02.prn' firstobs=2;
  input sex $ height weight chest 
        jitaku $ kodukai carrier $ tsuuwa;
proc format;                           : 階級を作る。class height の意
  value clheight low-<150='   -149'    : 階級の定義 1
                 150-<160='150-159'    :            2
                 160-<170='160-169'    :            3
                 170-<180='170-179'    :            4
                 180-high='180-   '    :            5
                 other   ='missing';   :            6
run;                                   :
proc print data=gakusei(obs=10);
run;
proc freq data=gakusei;                : 頻度を算出
  tables height;                       : 一変量ごとに
  format height clheight.;             : 連続変量をグループ化することの指定
run;                                   :
                                       :
proc freq data=gakusei;                : 頻度を算出
  tables sex*height;                   : 二変量の組合わせで
  format height clheight.;             : 連続変量をグループ化することの指定
run;                                   :
                                       :
proc sort data=gakusei;                : 今までの方法で実現しようとすると
  by sex;                              :
run;                                   :
proc freq data=gakusei;                :
  tables height;                       :
  format height clheight.;             : 連続変量をグループ化することの指定
  by sex;                              : 性別ごとに
run;                                   :
                              SAS システム                             2
                                             13:15 Monday, June 17, 2002
                                        Cumulative  Cumulative
          HEIGHT   Frequency   Percent   Frequency    Percent 
         -----------------------------------------------------
            -149          5       2.1           5        2.1  
         150-159         30      12.8          35       15.0  
         160-169         82      35.0         117       50.0  
         170-179        100      42.7         217       92.7  
         180-            17       7.3         234      100.0  
                         Frequency Missing = 9
                              SAS システム                             3
                                             13:15 Monday, June 17, 2002
                         TABLE OF SEX BY HEIGHT
     SEX       HEIGHT
     Frequency|
     Percent  |
     Row Pct  |
     Col Pct  |   -149 |150-159 |160-169 |170-179 |180-    |  Total
     ---------+--------+--------+--------+--------+--------+
     F        |      5 |     29 |     36 |      2 |      0 |     72
              |   2.15 |  12.45 |  15.45 |   0.86 |   0.00 |  30.90
              |   6.94 |  40.28 |  50.00 |   2.78 |   0.00 |
              | 100.00 |  96.67 |  44.44 |   2.00 |   0.00 |
     ---------+--------+--------+--------+--------+--------+
     M        |      0 |      1 |     45 |     98 |     17 |    161
              |   0.00 |   0.43 |  19.31 |  42.06 |   7.30 |  69.10
              |   0.00 |   0.62 |  27.95 |  60.87 |  10.56 |
              |   0.00 |   3.33 |  55.56 |  98.00 | 100.00 |
     ---------+--------+--------+--------+--------+--------+
     Total           5       30       81      100       17      233
                  2.15    12.88    34.76    42.92     7.30   100.00
     Frequency Missing = 10
                              SAS システム                             6
                                             13:15 Monday, June 17, 2002
------------------------------- SEX=' ' --------------------------------
                                        Cumulative  Cumulative
          HEIGHT   Frequency   Percent   Frequency    Percent 
         -----------------------------------------------------
         160-169          1     100.0           1      100.0  
                         Frequency Missing = 2
                              SAS システム                             7
                                             13:15 Monday, June 17, 2002
-------------------------------- SEX=F ---------------------------------
                                        Cumulative  Cumulative
          HEIGHT   Frequency   Percent   Frequency    Percent 
         -----------------------------------------------------
            -149          5       6.9           5        6.9  
         150-159         29      40.3          34       47.2  
         160-169         36      50.0          70       97.2  
         170-179          2       2.8          72      100.0  
                         Frequency Missing = 4
                              SAS システム                             8
                                             13:15 Monday, June 17, 2002
-------------------------------- SEX=M ---------------------------------
                                        Cumulative  Cumulative
          HEIGHT   Frequency   Percent   Frequency    Percent 
         -----------------------------------------------------
         150-159          1       0.6           1        0.6  
         160-169         45      28.0          46       28.6  
         170-179         98      60.9         144       89.4  
         180-            17      10.6         161      100.0  
                         Frequency Missing = 3
 /* Lesson 10-3 */
 /*    File Name = les1003.sas   06/20/02   */
data gakusei;
  infile 'all02.prn' firstobs=2;
  input sex $ height weight chest 
        jitaku $ kodukai carrier $ tsuuwa;
proc format;
  value clheight low-<150='   -149'
                 150-<160='150-159'
                 160-<170='160-169'
                 170-<180='170-179'
                 180-high='180-   '
                 other   ='missing';
run;
proc print data=gakusei(obs=10);
run;
proc tabulate data=gakusei;                : 要約統計量の表の作成
  class sex jitaku;                        : 特性変数であることの宣言
  var height;                              : 集計する変量名
  tables height*(n mean std),sex*jitaku;   : 表示内容、分類変量名
run;                                       :
proc tabulate data=gakusei;                :
  class height sex;                        :
  var weight;                              :
  tables weight*(n mean std),height*sex;   :
  format height clheight.;                 : 連続変量をグループ化することの指定
run;                                       :
                              SAS システム                             2
                                             14:45 Monday, June 17, 2002
 ----------------------------------------------------------------------
 |                |                        SEX                        |
 |                |---------------------------------------------------|
 |                |            F            |            M            |
 |                |-------------------------+-------------------------|
 |                |         JITAKU          |         JITAKU          |
 |                |-------------------------+-------------------------|
 |                |     G      |     J      |     G      |     J      |
 |----------------+------------+------------+------------+------------|
 |HEIGHT |N       |       19.00|       46.00|       55.00|       86.00|
 |       |--------+------------+------------+------------+------------|
 |       |MEAN    |      160.55|      158.61|      172.61|      171.68|
 |       |--------+------------+------------+------------+------------|
 |       |STD     |        5.81|        5.60|        4.71|        5.71|
 ----------------------------------------------------------------------
                              SAS システム                             3
                                             14:45 Monday, June 17, 2002
 ----------------------------------------------------------------------
 |                |                      HEIGHT                       |
 |                |---------------------------------------------------|
 |                |    -149    |         150-159         |  160-169   |
 |                |------------+-------------------------+------------|
 |                |    SEX     |           SEX           |    SEX     |
 |                |------------+-------------------------+------------|
 |                |     F      |     F      |     M      |     F      |
 |----------------+------------+------------+------------+------------|
 |WEIGHT |N       |        4.00|       22.00|        1.00|       23.00|
 |       |--------+------------+------------+------------+------------|
 |       |MEAN    |       42.00|       47.07|       61.00|       50.72|
 |       |--------+------------+------------+------------+------------|
 |       |STD     |        2.94|        5.10|           .|        3.54|
 ----------------------------------------------------------------------
 (CONTINUED)
                              SAS システム                             4
                                             14:45 Monday, June 17, 2002
 ----------------------------------------------------------------------
 |                |                      HEIGHT                       |
 |                |---------------------------------------------------|
 |                |  160-169   |         170-179         |    180-    |
 |                |------------+-------------------------+------------|
 |                |    SEX     |           SEX           |    SEX     |
 |                |------------+-------------------------+------------|
 |                |     M      |     F      |     M      |     M      |
 |----------------+------------+------------+------------+------------|
 |WEIGHT |N       |       45.00|        0.00|       98.00|       17.00|
 |       |--------+------------+------------+------------+------------|
 |       |MEAN    |       58.21|           .|       62.96|       67.50|
 |       |--------+------------+------------+------------+------------|
 |       |STD     |        7.35|           .|        7.05|        8.57|
 ----------------------------------------------------------------------