spss中syntax经典程序
spss中compute生成随机数:
INPUT PROGRAM.
- LOOP #I=1 TO 1000.
- COMPUTE Uniform_Distribution = UNIFORM(100).
- COMPUTE Normal_Distribution = RV.NORMAL(50,25).
- COMPUTE Poisson_Distribution = RV.POISSON(50).
- END CASE.
- END LOOP.
- END FILE.
END INPUT PROGRAM.
FREQUENCIES VARIABLES = ALL
/HISTOGRAM /FORMAT = NOTABLE.
spss计算字符长度并降序排列
COMPUTE strlength=LENGTH(RTRIM(stringvar)).
SORT CASES BY strlength (D).
spss电话号码用-组合
*concat_string.sps.
DATA LIST FREE /tel1 tel2 tel3 (3F4).
BEGIN DATA
111 222 3333
222 333 4444
333 444 5555
555 666 707
END DATA.
STRING telephone (A12).
COMPUTE telephone =
CONCAT((STRING(tel1, N3)), "-",
(STRING(tel2, N3)), "-",
(STRING(tel3, N4))).
EXECUTE.
spss中LAG函数
COMPUTE lagvar2=LAG(var2).
EXECUTE.
COMPUTE var2=var2*2.
EXECUTE.