Ⅰ spss語法程序如何編寫
libname a 『e:\data\』;
data a.student;
infile 『e:\data\student.txt』;
input name height weight;
以上程序將目錄「e:\data\」下的文本文件「student.txt」中的數據輸入數據集student中,該數據集存放於目錄「e:\data\」下。
(2)直接輸入方式
數據量較少或操作者意志力堅強的情況下採用此種輸入方式,在data語句之後寫入如下語句:
input變數名1變數名2 …變數名n;
datalines;(在以前的版本下為cards,新版本下兩者可通用)
… … … …(數據行)
… … … …(數據行)
… … … …(數據行)
;
datalines語句用於直接輸入數據,標志著數據塊的開始。
注意:這里的數據行中數據之間以空格分隔,當然也可以其它東東如逗號等來分隔,這里大家先以空格來分隔好了。因為不同的分隔方式下input語句要採取相應的控制選項,這些我們以後再討論,這里我們還是省省力氣吧。另外數據行輸完後不能像其它語句那樣直接在後面加上分號,而要另起一行輸入分號,這樣SAS才認為這是在輸入原始數據而不是在搞別的什麼。
Ⅱ SPSS Nemenyi檢驗方法編程
SPSS編程
通過菜單選擇:File-New-Syntax,打開語句編輯窗口(SyntaxEditor)編寫程序(也可以在word或其他文本編輯軟體中編寫,通過復制粘貼方式將程序粘貼到此窗口),若已建立程序,可通過File--+Open--+Syntax直接打開。
程序一(7組):
data
list
free/Hc
r1
r2
r3
r4
r5
r6
r7
N
n1
n2
n3
n4
n5
n6
n7.
begin
data
*
請於此行輸入Kruskal-Wallis
H
檢驗的結果(即Hc
r1
r2
r3
r4
r5
r6
r7
N
n1
n2
n3
n4
n5
n6
n7,盡量精確)
end
data.
compute
H=(12*((r1*n1)**2/n1+(r2*n2)**2/n2+(r3*n3)**2/n3+(r4*n4)**2/n4+(r5*n5)**2/n5+(r6*n6)**2/n6+(r7*n7)**2/n7))/(N*(N+1))-3*(N+1).
compute
c=H/Hc.
compute
x12=(r1-r2)**2/((N*(N+1)/12)*(1/n1+1/n2)*c).
compute
x13=(r1-r3)**2/((N*(N+1)/12)*(1/n1+1/n3)*c).
compute
x14=(r1-r4)**2/((N*(N+1)/12)*(1/n1+1/n4)*c).
compute
x15=(r1-r5)**2/((N*(N+1)/12)*(1/n1+1/n5)*c).
compute
x16=(r1-r6)**2/((N*(N+1)/12)*(1/n1+1/n6)*c).
compute
x17=(r1-r7)**2/((N*(N+1)/12)*(1/n1+1/n7)*c).
compute
x23=(r2-r3)**2/((N*(N+1)/12)*(1/n2+1/n3)*c).
compute
x24=(r2-r4)**2/((N*(N+1)/12)*(1/n2+1/n4)*c).
compute
x25=(r2-r5)**2/((N*(N+1)/12)*(1/n2+1/n5)*c).
compute
x26=(r2-r6)**2/((N*(N+1)/12)*(1/n2+1/n6)*c).
compute
x27=(r2-r7)**2/((N*(N+1)/12)*(1/n2+1/n7)*c).
compute
x34=(r3-r4)**2/((N*(N+1)/12)*(1/n3+1/n4)*c).
compute
x35=(r3-r5)**2/((N*(N+1)/12)*(1/n3+1/n5)*c).
compute
x36=(r3-r6)**2/((N*(N+1)/12)*(1/n3+1/n6)*c).
compute
x37=(r3-r7)**2/((N*(N+1)/12)*(1/n3+1/n7)*c).
compute
x45=(r4-r5)**2/((N*(N+1)/12)*(1/n4+1/n5)*c).
compute
x46=(r4-r6)**2/((N*(N+1)/12)*(1/n4+1/n6)*c).
compute
x47=(r4-r7)**2/((N*(N+1)/12)*(1/n4+1/n7)*c).
compute
x56=(r5-r6)**2/((N*(N+1)/12)*(1/n5+1/n6)*c).
compute
x57=(r5-r7)**2/((N*(N+1)/12)*(1/n5+1/n7)*c).
compute
x67=(r6-r7)**2/((N*(N+1)/12)*(1/n6+1/n7)*c).
compute
p12=1-cdf.chisq(x12,2).
compute
p13=1-cdf.chisq(x13,2).
compute
p14=1-cdf.chisq(x14,2).
compute
p15=1-cdf.chisq(x15,2).
compute
p16=1-cdf.chisq(x16,2).
compute
p17=1-cdf.chisq(x17,2).
compute
p23=1-cdf.chisq(x23,2).
compute
p24=1-cdf.chisq(x24,2).
compute
p25=1-cdf.chisq(x25,2).
compute
p26=1-cdf.chisq(x26,2).
compute
p27=1-cdf.chisq(x27,2).
compute
p34=1-cdf.chisq(x34,2).
compute
p35=1-cdf.chisq(x35,2).
compute
p36=1-cdf.chisq(x36,2).
compute
p37=1-cdf.chisq(x37,2).
compute
p45=1-cdf.chisq(x45,2).
compute
p46=1-cdf.chisq(x46,2).
compute
p47=1-cdf.chisq(x47,2).
compute
p56=1-cdf.chisq(x56,2).
compute
p57=1-cdf.chisq(x57,2).
compute
p67=1-cdf.chisq(x67,2).
execute.
復制代碼
註:少於7組的,刪掉相應的行與變數即可。
******
舉例3組:
data
list
free
/Hc
r1
r2
r3
N
n1
n2
n3.
begin
data
9.94
8.40
18.78
19.27
30
10
9
11
end
data.
COMPUTE
H
=
(12*((r1*n1)**2/n1+(r2*n2)**2/n2+(r3*n3)**2/n3))/(N*(N+1))-3*(N+1).
compute
C
=
H/Hc.
compute
x12
=
(r1-r2)**2/((N*(N+1)/12)*(1/n1+1/n2)*c).
compute
x13
=
(r1-r3)**2/((N*(N+1)/12)*(1/n1+1/n3)*c).
compute
x23
=
(r2-r3)**2/((N*(N+1)/12)*(1/n2+1/n3)*c).
compute
p12
=
1-cdf.chisq(x12,2).
compute
p13
=
1-cdf.chisq(x13,2).
compute
p23
=
1-cdf.chisq(x23,2).
execute.
結果:
舉例4組:
data
list
free
/Hc
r1
r2
r3
r4
N
n1
n2
n3
n4.
begin
data
27.625
44
33.46
23.29
13.25
56
14
14
14
14
end
data.
COMPUTE
H
=
(12*((r1*n1)**2/n1+(r2*n2)**2/n2+(r3*n3)**2/n3)+(r4*n4)**2/n4)/(N*(N+1))-3*(N+1).
compute
C
=
H/Hc.
compute
x12
=
(r1-r2)**2/((N*(N+1)/12)*(1/n1+1/n2)*c).
compute
x13
=
(r1-r3)**2/((N*(N+1)/12)*(1/n1+1/n3)*c).
compute
x14
=
(r1-r4)**2/((N*(N+1)/12)*(1/n1+1/n4)*c).
compute
x23
=
(r2-r3)**2/((N*(N+1)/12)*(1/n2+1/n3)*c).
compute
x24
=
(r2-r4)**2/((N*(N+1)/12)*(1/n2+1/n4)*c).
compute
x34
=
(r3-r4)**2/((N*(N+1)/12)*(1/n3+1/n4)*c).
compute
p12
=
1-cdf.chisq(x12,2).
compute
p13
=
1-cdf.chisq(x13,2).
compute
p14
=
1-cdf.chisq(x14,2).
compute
p23
=
1-cdf.chisq(x23,2).
compute
p24
=
1-cdf.chisq(x24,2).
compute
p34
=
1-cdf.chisq(x34,2).
execute.
結果: