1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 dnl GNU General Public License for more details.
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
17 AT_BANNER([DESCRIPTIVES procedure])
19 AT_SETUP([DESCRIPTIVES basics])
20 AT_DATA([descriptives.sps],
21 [title 'Test DESCRIPTIVES procedure'.
23 data list / V0 to V16 1-17.
37 descript all/stat=all/format=serial.
39 AT_CHECK([pspp -O format=csv descriptives.sps], [0], [dnl
40 Table: Reading 1 record from INLINE.
41 Variable,Record,Columns,Format
60 Table: Descriptive Statistics
61 ,N,Mean,S.E. Mean,Std Dev,Variance,Kurtosis,S.E. Kurt,Skewness,S.E. Skew,Range,Minimum,Maximum,Sum
62 V0,10,3.80,.84,2.66,7.07,-.03,1.33,.89,.69,8.00,1,9,38.00
63 V1,10,4.60,.96,3.03,9.16,-1.39,1.33,-.03,.69,9.00,0,9,46.00
64 V2,10,4.10,1.16,3.67,13.43,-2.02,1.33,.48,.69,8.00,1,9,41.00
65 V3,10,4.10,.87,2.77,7.66,-2.05,1.33,.42,.69,7.00,1,8,41.00
66 V4,10,7.00,.47,1.49,2.22,7.15,1.33,-2.52,.69,5.00,3,8,70.00
67 V5,10,4.90,1.03,3.25,10.54,-1.40,1.33,-.20,.69,9.00,0,9,49.00
68 V6,10,5.90,.80,2.51,6.32,-.29,1.33,-.96,.69,7.00,1,8,59.00
69 V7,10,4.70,1.10,3.47,12.01,-1.99,1.33,-.16,.69,9.00,0,9,47.00
70 V8,10,4.10,1.10,3.48,12.10,-1.93,1.33,.37,.69,9.00,0,9,41.00
71 V9,10,4.30,.87,2.75,7.57,-.87,1.33,.73,.69,8.00,1,9,43.00
72 V10,10,5.50,.85,2.68,7.17,-1.84,1.33,-.33,.69,7.00,2,9,55.00
73 V11,10,6.50,.78,2.46,6.06,-1.28,1.33,-.89,.69,6.00,3,9,65.00
74 V12,10,7.90,.60,1.91,3.66,5.24,1.33,-2.21,.69,6.00,3,9,79.00
75 V13,10,4.30,.99,3.13,9.79,-1.25,1.33,.33,.69,9.00,0,9,43.00
76 V14,10,3.60,1.01,3.20,10.27,-.96,1.33,.81,.69,9.00,0,9,36.00
77 V15,10,3.70,.92,2.91,8.46,-1.35,1.33,.71,.69,7.00,1,8,37.00
78 V16,10,6.40,.91,2.88,8.27,-1.14,1.33,-.92,.69,7.00,2,9,64.00
79 Valid N (listwise),10,,,,,,,,,,,,
80 Missing N (listwise),0,,,,,,,,,,,,
84 m4_define([DESCRIPTIVES_MISSING_DATA],
85 [data list notable / V1 TO V3 1-3.
98 AT_SETUP([DESCRIPTIVES -- excluding missing data])
99 AT_DATA([descriptives.sps],
100 [DESCRIPTIVES_MISSING_DATA
101 descript all/stat=all/format=serial.
103 AT_CHECK([pspp -O format=csv descriptives.sps], [0], [dnl
104 Table: Descriptive Statistics
105 ,N,Mean,S.E. Mean,Std Dev,Variance,Kurtosis,S.E. Kurt,Skewness,S.E. Skew,Range,Minimum,Maximum,Sum
106 V1,1,2.00,. ,. ,. ,. ,. ,. ,. ,.00,2,2,2.00
107 V2,2,2.50,.50,.71,.50,. ,. ,. ,. ,1.00,2,3,5.00
108 V3,3,3.00,.58,1.00,1.00,. ,. ,.00,1.22,2.00,2,4,9.00
109 Valid N (listwise),7,,,,,,,,,,,,
110 Missing N (listwise),6,,,,,,,,,,,,
114 AT_SETUP([DESCRIPTIVES -- including missing data])
115 AT_DATA([descriptives.sps],
116 [DESCRIPTIVES_MISSING_DATA
117 descript all/stat=all/format=serial/missing=include.
119 AT_CHECK([pspp -O format=csv descriptives.sps], [0], [dnl
120 Table: Descriptive Statistics
121 ,N,Mean,S.E. Mean,Std Dev,Variance,Kurtosis,S.E. Kurt,Skewness,S.E. Skew,Range,Minimum,Maximum,Sum
122 V1,5,1.20,.20,.45,.20,5.00,2.00,2.24,.91,1.00,1,2,6.00
123 V2,5,1.60,.40,.89,.80,.31,2.00,1.26,.91,2.00,1,3,8.00
124 V3,5,2.20,.58,1.30,1.70,-1.49,2.00,.54,.91,3.00,1,4,11.00
125 Valid N (listwise),7,,,,,,,,,,,,
126 Missing N (listwise),3,,,,,,,,,,,,
130 AT_SETUP([DESCRIPTIVES -- excluding missing data listwise])
131 AT_DATA([descriptives.sps],
132 [DESCRIPTIVES_MISSING_DATA
133 descript all/stat=all/format=serial/missing=listwise.
135 AT_CHECK([pspp -O format=csv descriptives.sps], [0], [dnl
136 Table: Descriptive Statistics
137 ,N,Mean,S.E. Mean,Std Dev,Variance,Kurtosis,S.E. Kurt,Skewness,S.E. Skew,Range,Minimum,Maximum,Sum
138 V1,1,2.00,. ,. ,. ,. ,. ,. ,. ,.00,2,2,2.00
139 V2,1,3.00,. ,. ,. ,. ,. ,. ,. ,.00,3,3,3.00
140 V3,1,4.00,. ,. ,. ,. ,. ,. ,. ,.00,4,4,4.00
141 Valid N (listwise),1,,,,,,,,,,,,
142 Missing N (listwise),6,,,,,,,,,,,,
146 AT_SETUP([DESCRIPTIVES -- including missing data listwise])
147 AT_DATA([descriptives.sps],
148 [DESCRIPTIVES_MISSING_DATA
149 descript all/stat=all/format=serial/missing=listwise include.
151 AT_CHECK([pspp -O format=csv descriptives.sps], [0], [dnl
152 Table: Descriptive Statistics
153 ,N,Mean,S.E. Mean,Std Dev,Variance,Kurtosis,S.E. Kurt,Skewness,S.E. Skew,Range,Minimum,Maximum,Sum
154 V1,4,1.25,.25,.50,.25,4.00,2.62,2.00,1.01,1.00,1,2,5.00
155 V2,4,1.75,.48,.96,.92,-1.29,2.62,.85,1.01,2.00,1,3,7.00
156 V3,4,2.50,.65,1.29,1.67,-1.20,2.62,.00,1.01,3.00,1,4,10.00
157 Valid N (listwise),4,,,,,,,,,,,,
158 Missing N (listwise),3,,,,,,,,,,,,
162 AT_SETUP([DESCRIPTIVES bug calculating mean only])
163 AT_DATA([descriptives.sps],
166 data list notable / X 1.
176 descript all/stat=mean.
178 AT_CHECK([pspp -O format=csv descriptives.sps], [0], [dnl
179 Table: Descriptive Statistics
182 Valid N (listwise),6,
183 Missing N (listwise),0,
187 dnl Git history shows that this was probably a bug in the PSPP
188 dnl core regarding multipass procedures, not anything specific
190 AT_SETUP([DESCRIPTIVES bug with TEMPORARY])
191 AT_DATA([descriptives.sps], [dnl
192 DATA LIST LIST NOTABLE /id * abc *.
206 DESCRIPTIVES /VAR=abc.
208 AT_CHECK([pspp -O format=csv descriptives.sps], [0], [dnl
209 Table: Descriptive Statistics
210 ,N,Mean,Std Dev,Minimum,Maximum
211 abc,6,3.00,.84,2.00,4.00
212 Valid N (listwise),6,,,,
213 Missing N (listwise),0,,,,
217 AT_SETUP([DESCRIPTIVES -- Z scores])
218 AT_DATA([descriptives.sps], [dnl
219 DATA LIST LIST NOTABLE /a b.
226 DESCRIPTIVES /VAR=a b /SAVE.
229 AT_CHECK([pspp -O format=csv descriptives.sps], [0], [dnl
230 Table: Mapping of Variables to Z-scores
235 Table: Descriptive Statistics
236 ,N,Mean,Std Dev,Minimum,Maximum
237 a,3,2.00,1.00,1.00,3.00
238 b,3,60.00,10.00,50.00,70.00
239 Valid N (listwise),3,,,,
240 Missing N (listwise),0,,,,
244 1.00,50.00,-1.00,-1.00
250 AT_SETUP([DESCRIPTIVES -- Z scores with SPLIT FILE])
251 AT_DATA([descriptives.sps], [dnl
252 DATA LIST LIST NOTABLE /group a b.
264 DESCRIPTIVES /VAR=a b /SAVE.
267 AT_CHECK([pspp -o pspp.csv -o pspp.txt descriptives.sps])
268 AT_CHECK([cat pspp.csv], [0], [dnl
269 Table: Mapping of Variables to Z-scores
278 Table: Descriptive Statistics
279 ,N,Mean,Std Dev,Minimum,Maximum
280 a,3,2.00,1.00,1.00,3.00
281 b,3,60.00,10.00,50.00,70.00
282 Valid N (listwise),3,,,,
283 Missing N (listwise),0,,,,
289 Table: Descriptive Statistics
290 ,N,Mean,Std Dev,Minimum,Maximum
291 a,4,300.00,182.57,100.00,500.00
292 b,4,8000.00,1825.74,6000.00,10000.00
293 Valid N (listwise),4,,,,
294 Missing N (listwise),0,,,,
302 1.00,1.00,50.00,-1.00,-1.00
303 1.00,2.00,60.00,.00,.00
304 1.00,3.00,70.00,1.00,1.00
312 2.00,100.00,6000.00,-1.10,-1.10
313 2.00,200.00,7000.00,-.55,-.55
314 2.00,400.00,9000.00,.55,.55
315 2.00,500.00,10000.00,1.10,1.10
319 dnl Ideally DESCRIPTIVES would not make temporary transformations permanent
320 dnl as it does now (bug #38786), so these results are imperfect. However,
321 dnl this test does verify that DESCRIPTIVES does not crash in this situation
322 dnl (as it once did).
323 AT_SETUP([DESCRIPTIVES -- Z scores bug with TEMPORARY])
324 AT_DATA([descriptives.sps], [dnl
325 DATA LIST LIST NOTABLE /id abc.
339 DESCRIPTIVES /VAR=abc/SAVE.
342 AT_CHECK([pspp -o pspp.csv -o pspp.txt descriptives.sps], [0], [dnl
343 descriptives.sps:15.23-15.26: warning: DESCRIPTIVES: DESCRIPTIVES with Z scores ignores TEMPORARY. Temporary transformations will be made permanent.
344 15 | DESCRIPTIVES /VAR=abc/SAVE.
347 AT_CHECK([cat pspp.csv], [0], [dnl
348 "descriptives.sps:15.23-15.26: warning: DESCRIPTIVES: DESCRIPTIVES with Z scores ignores TEMPORARY. Temporary transformations will be made permanent.
349 15 | DESCRIPTIVES /VAR=abc/SAVE.
352 Table: Mapping of Variables to Z-scores
356 Table: Descriptive Statistics
357 ,N,Mean,Std Dev,Minimum,Maximum
358 abc,6,3.00,.84,2.00,4.00
359 Valid N (listwise),6,,,,
360 Missing N (listwise),0,,,,
373 dnl This test was supplied by Mindaugus as part of the report for bug #42012.
374 AT_SETUP([DESCRIPTIVES -- Z scores with FILTER])
375 AT_DATA([descriptives.sps], [dnl
376 DATA LIST LIST/filter1 filter2 x.
390 DESCRIPTIVES /VARIABLES=X /SAVE.
394 DESCRIPTIVES /VARIABLES=X /SAVE.
397 SORT CASES BY filter1.
398 SPLIT FILE BY filter1.
399 DESCRIPTIVES /VARIABLES=X /SAVE.
402 SPLIT FILE BY filter1.
403 DESCRIPTIVES /VARIABLES=X /SAVE.
406 SORT CASES BY filter1 filter2.
407 SPLIT FILE BY filter1 filter2.
408 DESCRIPTIVES /VARIABLES=X /SAVE.
414 AT_CHECK([pspp -o pspp.csv descriptives.sps])
415 AT_CHECK([sed -n '/Table: Data List/,$p' < pspp.csv], [0], [dnl
417 filter1,filter2,x,Zx,ZSC001,ZSC002,ZSC003,ZSC004
418 .00,.00,300.00,1.94,. ,1.00,. ,. @&t@
419 .00,1.00,200.00,1.07,. ,.00,.71,.71
420 .00,1.00,100.00,.20,. ,-1.00,-.71,-.71
421 1.00,.00,5.00,-.62,1.26,1.26,. ,.71
422 1.00,.00,4.00,-.63,.63,.63,. ,-.71
423 1.00,1.00,3.00,-.64,.00,.00,1.00,1.00
424 1.00,1.00,2.00,-.65,-.63,-.63,.00,.00
425 1.00,1.00,1.00,-.66,-1.26,-1.26,-1.00,-1.00
429 dnl This is an example from doc/tutorial.texi
430 dnl So if the results of this have to be changed in any way,
431 dnl make sure to update that file.
432 AT_SETUP([DESCRIPTIVES tutorial example])
433 cp $top_srcdir/examples/physiology.sav .
434 AT_DATA([descriptives.sps], [dnl
435 GET FILE='physiology.sav'.
436 DESCRIPTIVES sex, weight, height.
438 AT_CHECK([pspp -o pspp.csv -o pspp.txt descriptives.sps])
439 AT_CHECK([cat pspp.csv], [0], [dnl
440 Table: Descriptive Statistics
441 ,N,Mean,Std Dev,Minimum,Maximum
442 Sex of subject ,40,.45,.50,Male,Female
443 Weight in kilograms ,40,72.12,26.70,-55.6,92.1
444 Height in millimeters ,40,1677.12,262.87,179,1903
445 Valid N (listwise),40,,,,
446 Missing N (listwise),0,,,,
450 AT_SETUP([DESCRIPTIVES syntax errors])
451 AT_DATA([descriptives.sps], [dnl
452 DATA LIST LIST NOTABLE /x y z.
453 DESCRIPTIVES MISSING=**.
454 DESCRIPTIVES FORMAT=**.
455 DESCRIPTIVES STATISTICS=**.
456 DESCRIPTIVES SORT=**.
457 DESCRIPTIVES SORT=NAME (**).
458 DESCRIPTIVES SORT=NAME (A **).
461 DESCRIPTIVES MISSING=INCLUDE.
463 NUMERIC Zx ZSC001 TO ZSC099 STDZ01 TO STDZ09 ZZZZ01 TO ZZZZ09 ZQZQ01 TO ZQZQ09.
466 AT_CHECK([pspp descriptives.sps], [1], [dnl
467 descriptives.sps:2.22-2.23: error: DESCRIPTIVES: Syntax error expecting
468 VARIABLE, LISTWISE, or INCLUDE.
469 2 | DESCRIPTIVES MISSING=**.
472 descriptives.sps:3.21-3.22: error: DESCRIPTIVES: Syntax error expecting LABELS,
473 NOLABELS, INDEX, NOINDEX, LINE, or SERIAL.
474 3 | DESCRIPTIVES FORMAT=**.
477 descriptives.sps:5.19-5.20: error: DESCRIPTIVES: Syntax error expecting
479 5 | DESCRIPTIVES SORT=**.
482 descriptives.sps:6.25-6.26: error: DESCRIPTIVES: Syntax error expecting A or D.
483 6 | DESCRIPTIVES SORT=NAME (**).
486 descriptives.sps:7.27-7.28: error: DESCRIPTIVES: Syntax error expecting `)'.
487 7 | DESCRIPTIVES SORT=NAME (A **).
490 descriptives.sps:8.14-8.15: error: DESCRIPTIVES: Syntax error expecting
495 descriptives.sps:9.17-9.18: error: DESCRIPTIVES: Syntax error expecting
496 MISSING, SAVE, FORMAT, STATISTICS, SORT, or VARIABLES.
497 9 | DESCRIPTIVES x/ **.
500 descriptives.sps:10: error: DESCRIPTIVES: No variables specified.
502 descriptives.sps:13: error: DESCRIPTIVES: Ran out of generic names for Z-score
503 variables. There are only 126 generic names: ZSC001-ZSC099, STDZ01-STDZ09,
504 ZZZZ01-ZZZZ09, ZQZQ01-ZQZQ09.