/* Lesson 13-01 */
/* File Name = les1301.sas 01/19/21 */
options nocenter linesize=78 pagesize=30;
options locale='en_US';
/* options locale='ja_JP'; */
proc printto print = 'StatM20/les1301-Results.txt' new;
data pair;
input x y @@; : 改行せずに続けて読むことの指定
dif=x-y; : 前後の差を計算
cards;
3.51 3.39 3.07 3.39 3.29 3.20 3.03 3.11 : 2つ1組みでデータを列挙
3.38 3.17 3.30 3.09 3.15 3.17 3.25 3.09 :
;
proc print data=pair;
run;
: Stem and Leaf を表示させるには
ods listing; : 以下の plot オプション用に指定。
ods graphics off; : 以下の plot オプション用に指定。
proc univariate data=pair plot; : 基礎統計量の算出。plot オプションを指定。
var dif; : 指定した変量について
run;
Tuesday, January 19, 2021 08:40:04 AM 11
Obs x y dif
1 3.51 3.39 0.12
2 3.07 3.39 -0.32
3 3.29 3.20 0.09
4 3.03 3.11 -0.08
5 3.38 3.17 0.21
6 3.30 3.09 0.21
7 3.15 3.17 -0.02
8 3.25 3.09 0.16
Tuesday, January 19, 2021 08:40:04 AM 12
The UNIVARIATE Procedure
Variable: dif
Moments
N 8 Sum Weights 8
Mean 0.04625 Sum Observations 0.37
Std Deviation 0.18062886 Variance 0.03262679
Skewness -1.3152288 Kurtosis 1.51109886
Uncorrected SS 0.2455 Corrected SS 0.2283875
Coeff Variation 390.54889 Std Error Mean 0.06386195
Basic Statistical Measures
Location Variability
Mean 0.046250 Std Deviation 0.18063
Median 0.105000 Variance 0.03263
Mode 0.210000 Range 0.53000
Interquartile Range 0.23500
Tuesday, January 19, 2021 08:40:04 AM 13
The UNIVARIATE Procedure
Variable: dif
Tests for Location: Mu0=0
Test -Statistic- -----p Value------
Student's t t 0.724218 Pr > |t| 0.4924
Sign M 1 Pr >= |M| 0.7266
Signed Rank S 7 Pr >= |S| 0.3594
Quantiles (Definition 5)
Level Quantile
100% Max 0.210
99% 0.210
95% 0.210
90% 0.210
75% Q3 0.185
50% Median 0.105
25% Q1 -0.050
10% -0.320
5% -0.320
1% -0.320
0% Min -0.320
Tuesday, January 19, 2021 08:40:04 AM 14
The UNIVARIATE Procedure
Variable: dif
Extreme Observations
----Lowest---- ----Highest---
Value Obs Value Obs
-0.32 2 0.09 3
-0.08 4 0.12 1
-0.02 7 0.16 8
0.09 3 0.21 5
0.12 1 0.21 6
Stem Leaf # Boxplot
2 11 2 |
1 26 2 +-----+
0 9 1 | + |
-0 82 2 +-----+
-1 |
-2 |
-3 2 1 |
----+----+----+----+
Multiply Stem.Leaf by 10**-1
Tuesday, January 19, 2021 08:40:04 AM 15
The UNIVARIATE Procedure
Variable: dif
Normal Probability Plot
0.25+ *++++*
| *++*+++
| *++++
-0.05+ *+++*++
| +++++
| ++++++
-0.35+ +++++ *
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
cards; 5.1 4.7 6.2 6.1 6.8 7.2 7.4 7.3 3.9 3.6 3.5 3.7 5.3 4.8 4.5 4.4 5.9 5.5 4.8 4.6
data example2020;
infile 'StatM20/foo1.csv'
firstobs=2
dlm=',' dsd
missover truncover
encoding=sjis termstr=crlf
;
input No $ Univ : $30. SName : $40. Faculty : $50. Dept : $50.
Center1 : $8. Center2 : $8. Sel1 : $8. Sel2 : $8.
Book1 : $10. Book2 : $10.
Vol0 VolS VolT
ZenKou $ ScoreS ScoreT KoKouSi
;
data example2020;
infile 'StatM20/foo2.txt'
firstobs=2
dlm='09'x
missover truncover
encoding=sjis termstr=crlf
;
data math;
infile 'StatM20/foo3.csv'
firstobs=2
dlm=',' dsd
lrecl=230
;
data math;
infile 'StatM20/foo4.csv'
firstobs=2
dlm=',' dsd
lrecl=230 truncover
;
input
UketsukeID 1- 6
JyukenID 7- 11
BirthDay 13- 20
Area $ 32- 41
s_scor01 103-104
s_scor02 105-106
s_scor03 107-108
;
/* Lesson 13-02 */
/* File Name = les1302.sas 01/19/21 */
options nocenter linesize=78 pagesize=30;
options locale='en_US';
/* options locale='ja_JP'; */
proc printto print = 'StatM20/les1302-Results.txt' new;
data gakusei;
infile 'StatM20/StudAll20e.csv'
firstobs=8 dlm=',' dsd missover
encoding=sjis termstr=crlf;
input sex $ shintyou taijyuu kyoui
jitaku : $10. kodukai carryer $ tsuuwa;
/* if shintyou="." or taijyuu="." or kyoui="." then delete; */
if carryer="DoCoMo" then carryer="docomo"; : 名称の不揃いを統一する
if carryer="DoCoMo+w" then carryer="docomo+W";
if carryer="vodafone" then carryer="Vodafone";
if carryer="au+willc" then carryer="au+Willc";
proc print data=gakusei(obs=5);
run;
title '*** 通常の頻度集計、クロス集計(アルファベット順になる) ***';
proc freq data=gakusei;
tables sex jitaku carryer;
run;
proc freq data=gakusei;
tables sex*jitaku;
tables sex*carryer;
tables jitaku*carryer;
run;
title '*** 頻度の大きい順に表示 ***';
proc freq data=gakusei order=freq; : 頻度順に
tables sex jitaku carryer;
run;
proc freq data=gakusei order=freq; : 頻度順に
tables sex*jitaku;
tables sex*carryer;
tables jitaku*carryer;
run;
title '*** 頻度の大きい順に表示(頻度のみ) ***';
proc freq data=gakusei order=freq; : 頻度順に
tables sex jitaku carryer / nopercent norow nocol; : 頻度のみ
run;
proc freq data=gakusei order=freq; : 頻度順に
tables sex*jitaku / nopercent norow nocol;
tables sex*carryer / nopercent norow nocol;
tables jitaku*carryer / nopercent norow nocol;
run;
*** 通常の頻度集計、クロス集計(アルファベット順にな 2
Monday, January 18, 2021 09:43:03 PM
The FREQ Procedure
Cumulative Cumulative
sex Frequency Percent Frequency Percent
--------------------------------------------------------
F 124 33.51 124 33.51
M 246 66.49 370 100.00
Frequency Missing = 124
Cumulative Cumulative
jitaku Frequency Percent Frequency Percent
--------------------------------------------------------------
下宿生 155 35.80 155 35.80
自宅生 278 64.20 433 100.00
Frequency Missing = 61
*** 通常の頻度集計、クロス集計(アルファベット順にな 3
Monday, January 18, 2021 09:43:03 PM
The FREQ Procedure
Cumulative Cumulative
carryer Frequency Percent Frequency Percent
-------------------------------------------------------------
DDIp 2 1.34 2 1.34
J-PHONE 10 6.71 12 8.05
KDDI 1 0.67 13 8.72
No 5 3.36 18 12.08
OCN 1 0.67 19 12.75
UQ-mobil 1 0.67 20 13.42
Vodafone 21 14.09 41 27.52
Willcom 1 0.67 42 28.19
au 39 26.17 81 54.36
au+Willc 1 0.67 82 55.03
docomo 65 43.62 147 98.66
docomo+w 1 0.67 148 99.33
softbank 1 0.67 149 100.00
Frequency Missing = 345
*** 通常の頻度集計、クロス集計(アルファベット順にな 4
Monday, January 18, 2021 09:43:03 PM
The FREQ Procedure
Table of sex by jitaku
sex jitaku
Frequency|
Percent |
Row Pct |
Col Pct |下宿 |自宅 | Total
|生 |生 |
---------+--------+--------+
F | 36 | 70 | 106
| 11.29 | 21.94 | 33.23
| 33.96 | 66.04 |
| 30.25 | 35.00 |
---------+--------+--------+
M | 83 | 130 | 213
| 26.02 | 40.75 | 66.77
| 38.97 | 61.03 |
| 69.75 | 65.00 |
---------+--------+--------+
Total 119 200 319
37.30 62.70 100.00
Frequency Missing = 175
*** 通常の頻度集計、クロス集計(アルファベット順にな 5
Monday, January 18, 2021 09:43:03 PM
The FREQ Procedure
Table of sex by carryer
sex carryer
Frequency|
Percent |
Row Pct |
Col Pct |DDIp |J-PHONE |KDDI |No |OCN | Total
---------+--------+--------+--------+--------+--------+
F | 1 | 4 | 0 | 1 | 0 | 56
| 0.68 | 2.74 | 0.00 | 0.68 | 0.00 | 38.36
| 1.79 | 7.14 | 0.00 | 1.79 | 0.00 |
| 50.00 | 44.44 | 0.00 | 20.00 | . |
---------+--------+--------+--------+--------+--------+
M | 1 | 5 | 1 | 4 | 0 | 90
| 0.68 | 3.42 | 0.68 | 2.74 | 0.00 | 61.64
| 1.11 | 5.56 | 1.11 | 4.44 | 0.00 |
| 50.00 | 55.56 | 100.00 | 80.00 | . |
---------+--------+--------+--------+--------+--------+
Total 2 9 1 5 0 146
1.37 6.16 0.68 3.42 0.00 100.00
(Continued)
*** 通常の頻度集計、クロス集計(アルファベット順にな 6
Monday, January 18, 2021 09:43:03 PM
The FREQ Procedure
Table of sex by carryer
sex carryer
Frequency|
Percent |
Row Pct |
Col Pct |UQ-mobil|Vodafone|Willcom |au |au+Willc| Total
---------+--------+--------+--------+--------+--------+
F | 0 | 9 | 1 | 12 | 1 | 56
| 0.00 | 6.16 | 0.68 | 8.22 | 0.68 | 38.36
| 0.00 | 16.07 | 1.79 | 21.43 | 1.79 |
| . | 42.86 | 100.00 | 30.77 | 100.00 |
---------+--------+--------+--------+--------+--------+
M | 0 | 12 | 0 | 27 | 0 | 90
| 0.00 | 8.22 | 0.00 | 18.49 | 0.00 | 61.64
| 0.00 | 13.33 | 0.00 | 30.00 | 0.00 |
| . | 57.14 | 0.00 | 69.23 | 0.00 |
---------+--------+--------+--------+--------+--------+
Total 0 21 1 39 1 146
0.00 14.38 0.68 26.71 0.68 100.00
(Continued)
*** 通常の頻度集計、クロス集計(アルファベット順にな 7
Monday, January 18, 2021 09:43:03 PM
The FREQ Procedure
Table of sex by carryer
sex carryer
Frequency|
Percent |
Row Pct |
Col Pct |docomo |docomo+w|softbank| Total
---------+--------+--------+--------+
F | 26 | 0 | 1 | 56
| 17.81 | 0.00 | 0.68 | 38.36
| 46.43 | 0.00 | 1.79 |
| 40.00 | 0.00 | 100.00 |
---------+--------+--------+--------+
M | 39 | 1 | 0 | 90
| 26.71 | 0.68 | 0.00 | 61.64
| 43.33 | 1.11 | 0.00 |
| 60.00 | 100.00 | 0.00 |
---------+--------+--------+--------+
Total 65 1 1 146
44.52 0.68 0.68 100.00
Frequency Missing = 348
≪中略≫
*** 頻度の大きい順に表示 *** 11
Monday, January 18, 2021 09:43:03 PM
The FREQ Procedure
Cumulative Cumulative
sex Frequency Percent Frequency Percent
--------------------------------------------------------
M 246 66.49 246 66.49
F 124 33.51 370 100.00
Frequency Missing = 124
Cumulative Cumulative
jitaku Frequency Percent Frequency Percent
--------------------------------------------------------------
自宅生 278 64.20 278 64.20
下宿生 155 35.80 433 100.00
Frequency Missing = 61
*** 頻度の大きい順に表示 *** 12
Monday, January 18, 2021 09:43:03 PM
The FREQ Procedure
Cumulative Cumulative
carryer Frequency Percent Frequency Percent
-------------------------------------------------------------
docomo 65 43.62 65 43.62
au 39 26.17 104 69.80
Vodafone 21 14.09 125 83.89
J-PHONE 10 6.71 135 90.60
No 5 3.36 140 93.96
DDIp 2 1.34 142 95.30
KDDI 1 0.67 143 95.97
OCN 1 0.67 144 96.64
UQ-mobil 1 0.67 145 97.32
Willcom 1 0.67 146 97.99
au+Willc 1 0.67 147 98.66
docomo+w 1 0.67 148 99.33
softbank 1 0.67 149 100.00
Frequency Missing = 345
*** 頻度の大きい順に表示 *** 13
Monday, January 18, 2021 09:43:03 PM
The FREQ Procedure
Table of sex by jitaku
sex jitaku
Frequency|
Percent |
Row Pct |
Col Pct |自宅 |下宿 | Total
|生 |生 |
---------+--------+--------+
M | 130 | 83 | 213
| 40.75 | 26.02 | 66.77
| 61.03 | 38.97 |
| 65.00 | 69.75 |
---------+--------+--------+
F | 70 | 36 | 106
| 21.94 | 11.29 | 33.23
| 66.04 | 33.96 |
| 35.00 | 30.25 |
---------+--------+--------+
Total 200 119 319
62.70 37.30 100.00
Frequency Missing = 175
*** 頻度の大きい順に表示 *** 14
Monday, January 18, 2021 09:43:03 PM
The FREQ Procedure
Table of sex by carryer
sex carryer
Frequency|
Percent |
Row Pct |
Col Pct |docomo |au |Vodafone|J-PHONE |No | Total
---------+--------+--------+--------+--------+--------+
M | 39 | 27 | 12 | 5 | 4 | 90
| 26.71 | 18.49 | 8.22 | 3.42 | 2.74 | 61.64
| 43.33 | 30.00 | 13.33 | 5.56 | 4.44 |
| 60.00 | 69.23 | 57.14 | 55.56 | 80.00 |
---------+--------+--------+--------+--------+--------+
F | 26 | 12 | 9 | 4 | 1 | 56
| 17.81 | 8.22 | 6.16 | 2.74 | 0.68 | 38.36
| 46.43 | 21.43 | 16.07 | 7.14 | 1.79 |
| 40.00 | 30.77 | 42.86 | 44.44 | 20.00 |
---------+--------+--------+--------+--------+--------+
Total 65 39 21 9 5 146
44.52 26.71 14.38 6.16 3.42 100.00
(Continued)
≪中略≫
*** 頻度の大きい順に表示(頻度のみ) *** 20
Monday, January 18, 2021 09:43:03 PM
The FREQ Procedure
Cumulative
sex Frequency Frequency
------------------------------
M 246 246
F 124 370
Frequency Missing = 124
Cumulative
jitaku Frequency Frequency
------------------------------------
自宅生 278 278
下宿生 155 433
Frequency Missing = 61
*** 頻度の大きい順に表示(頻度のみ) *** 21
Monday, January 18, 2021 09:43:03 PM
The FREQ Procedure
Cumulative
carryer Frequency Frequency
-----------------------------------
docomo 65 65
au 39 104
Vodafone 21 125
J-PHONE 10 135
No 5 140
DDIp 2 142
KDDI 1 143
OCN 1 144
UQ-mobil 1 145
Willcom 1 146
au+Willc 1 147
docomo+w 1 148
softbank 1 149
Frequency Missing = 345
*** 頻度の大きい順に表示(頻度のみ) *** 22
Monday, January 18, 2021 09:43:03 PM
The FREQ Procedure
Table of sex by jitaku
sex jitaku
Frequency|自宅 |下宿 | Total
|生 |生 |
---------+--------+--------+
M | 130 | 83 | 213
---------+--------+--------+
F | 70 | 36 | 106
---------+--------+--------+
Total 200 119 319
Frequency Missing = 175
*** 頻度の大きい順に表示(頻度のみ) *** 23
Monday, January 18, 2021 09:43:03 PM
The FREQ Procedure
Table of sex by carryer
sex carryer
Frequency|docomo |au |Vodafone|J-PHONE |No | Total
---------+--------+--------+--------+--------+--------+
M | 39 | 27 | 12 | 5 | 4 | 90
---------+--------+--------+--------+--------+--------+
F | 26 | 12 | 9 | 4 | 1 | 56
---------+--------+--------+--------+--------+--------+
Total 65 39 21 9 5 146
(Continued)
≪後略≫
≪前略≫ if carryer="DoCoMo" then carryer="docomo"; if carryer="DoCoMo+w" then carryer="docomo+W"; if carryer="vodafone" then carryer="Vodafone"; if carryer="au+willc" then carryer="au+Willc"; ≪後略≫
≪前略≫ title '*** 頻度の大きい順に表示 ***'; proc freq data=gakusei order=freq; tables sex jitaku carryer; run; proc freq data=gakusei order=freq; tables sex*jitaku; tables sex*carryer; tables jitaku*carryer; run; ≪後略≫
≪前略≫ title '*** 頻度の大きい順に表示(頻度のみ) ***'; proc freq data=gakusei order=freq; tables sex jitaku carryer / nopercent norow nocol; run; proc freq data=gakusei order=freq; tables sex*jitaku / nopercent norow nocol; tables sex*carryer / nopercent norow nocol; tables jitaku*carryer / nopercent norow nocol; run; ≪後略≫
≪前略≫ title '*** 3重クロス集計 ***'; proc freq data=gakusei; tables sex*jitaku*carryer; run;
≪前略≫
proc corr data=gakusei;; : 相関係数
var shintyou taijyuu kyoui
kodukai tsuuwa;
run;
title "Scatterplot Matrix";
proc sgscatter data=gakusei; : 散布図行列
matrix shintyou taijyuu kyoui : 変量を指定
kodukai tsuuwa;
run;
title "Scatterplot Matrix grouped sex";
proc sgscatter data=gakusei; : 散布図行列
matrix shintyou taijyuu kyoui : 変量を指定
kodukai tsuuwa
/ group=sex; : 区別する変量を指定
run;