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/>.
19 AT_SETUP([RANK simple case with defaults])
20 AT_DATA([rank.sps], [dnl
21 DATA LIST LIST NOTABLE /x (f8).
36 AT_CHECK([pspp -o pspp.csv rank.sps])
37 AT_CHECK([cat pspp.csv], [0], [dnl
38 Variables Created By RANK
56 # This checks for regression against a crash reported as bug #38482
57 # that occurred when multiple variables were specified without any
58 # rank specifications.
59 AT_SETUP([RANK multiple variables with defaults])
60 AT_DATA([rank.sps], [dnl
61 DATA LIST LIST NOTABLE /x * y * z *.
71 AT_CHECK([pspp -o pspp.csv rank.sps])
72 AT_CHECK([cat pspp.csv], [0], [dnl
73 Variables Created By RANK
85 1.00,2.00,3.00,1.000,1.000,1.000
86 4.00,5.00,6.00,2.000,2.000,2.000
90 AT_SETUP([RANK with RANK, RFRACTION, N])
91 AT_DATA([rank.sps], [dnl
92 DATA LIST LIST NOTABLE /a * b *.
118 AT_CHECK([pspp -o pspp.csv rank.sps])
119 AT_CHECK([cat pspp.csv], [0], [dnl
120 Variables Created By RANK
128 a into RFR001(RFRACTION of a)
130 b into RFR002(RFRACTION of b)
136 Variable,Description,Position
141 RFR001,"Label: RFRACTION of a
147 RFR002,"Label: RFRACTION of b
153 a,b,Ra,RFR001,count,Rb,RFR002,Nb
154 .00,24.00,10.000,1.0000,10,8.000,.8889,9
155 1.00,32.00,9.000,.9000,10,4.000,.4444,9
156 2.00,31.00,8.000,.8000,10,5.000,.5556,9
157 2.00,32.00,8.000,.8000,10,4.000,.4444,9
158 4.00,30.00,6.000,.6000,10,6.000,.6667,9
159 5.00,29.00,5.000,.5000,10,7.000,.7778,9
160 6.00,1.00,4.000,.4000,10,9.000,1.0000,9
161 7.00,43.00,3.000,.3000,10,2.000,.2222,9
162 8.00,. ,2.000,.2000,10,. ,. ,.
163 9.00,45.00,1.000,.1000,10,1.000,.1111,9
167 AT_SETUP([RANK with SAVAGE, PERCENT, PROPORTION, NTILES])
168 AT_DATA([rank.sps], [dnl
169 DATA LIST LIST NOTABLE /a * b *.
195 AT_CHECK([pspp -o pspp.csv rank.sps])
196 AT_CHECK([cat pspp.csv], [0], [dnl
197 Variables Created By RANK
201 a into Sa(SAVAGE of a)
203 a into Pa(PERCENT of a)
205 a into PRO001(PROPORTION of a using BLOM)
207 a into Na(NTILES of a)
209 a into NOR001(NORMAL of a using BLOM)
212 a,b,Sa,Pa,PRO001,Na,NOR001
213 .00,24.00,-.9000,10.00,.0610,1,-1.547
214 1.00,32.00,-.7889,20.00,.1585,1,-1.000
215 2.00,31.00,-.5925,30.00,.2561,2,-.6554
216 2.00,32.00,-.5925,30.00,.2561,2,-.6554
217 4.00,30.00,-.3544,40.00,.3537,2,-.3755
218 5.00,29.00,-.1544,50.00,.4512,2,-.1226
219 6.00,1.00,.0956,60.00,.5488,3,.1226
220 7.00,43.00,.4290,70.00,.6463,3,.3755
221 8.00,8.00,.9290,80.00,.7439,3,.6554
222 9.00,45.00,1.9290,90.00,.8415,4,1.0005
226 AT_SETUP([RANK with SPLIT FILE])
227 AT_DATA([rank.sps], [dnl
228 DATA LIST LIST NOTABLE /a * g1 g2 *.
274 AT_CHECK([pspp -o pspp.csv rank.sps])
275 AT_CHECK([cat pspp.csv], [0], [dnl
276 Variables Created By RANK
280 a into Ra(RANK of a BY g2 g1)
282 a into Na(NORMAL of a using RANKIT BY g2 g1)
284 Variables Created By RANK
288 a into RAN001(RANK of a BY g2)
290 a into NOR001(NORMAL of a using RANKIT BY g2)
293 a,g1,g2,Ra,Na,RAN001,NOR001
294 2.00,1.00,2.00,8.000,.9674,4.000,.5244
295 2.00,1.00,2.00,8.000,.9674,4.000,.5244
296 3.00,1.00,2.00,7.000,.5895,3.000,.0000
297 4.00,1.00,2.00,6.000,.2822,2.000,-.5244
298 5.00,1.00,2.00,5.000,.0000,1.000,-1.282
299 1.00,.00,2.00,8.000,1.5341,8.000,1.5341
300 2.00,.00,2.00,7.000,.8871,7.000,.8871
301 3.00,.00,2.00,6.000,.4888,6.000,.4888
302 4.00,.00,2.00,5.000,.1573,5.000,.1573
303 5.00,.00,2.00,4.000,-.1573,4.000,-.1573
304 6.00,.00,2.00,3.000,-.4888,3.000,-.4888
305 7.00,.00,2.00,2.000,-.8871,2.000,-.8871
306 8.00,.00,2.00,1.000,-1.534,1.000,-1.534
307 6.00,1.00,2.00,4.000,-.2822,4.000,1.1503
308 7.00,1.00,2.00,2.000,-.9674,2.000,-.3186
309 7.00,1.00,2.00,2.000,-.9674,2.000,-.3186
310 8.00,1.00,2.00,1.000,-1.593,1.000,-1.150
311 9.00,1.00,1.00,1.000,.0000,1.000,.0000
315 # Also tests small ranks for special case of SAVAGE ranks.
316 AT_SETUP([RANK with fractional ranks])
317 AT_DATA([rank.sps], [dnl
318 DATA LIST LIST NOTABLE /a * w * .
340 AT_CHECK([pspp -o pspp.csv rank.sps])
341 AT_CHECK([cat pspp.csv], [0], [dnl
342 Variables Created By RANK
346 a into Pa(PROPORTION of a using TUKEY)
348 a into Sa(SAVAGE of a)
352 1.00,1.50,.1285,-.8016
353 2.00,.20,.1776,-.6905
354 3.00,.10,.1986,-.6905
355 4.00,1.00,.3458,-.5305
356 5.00,1.00,.4860,-.2905
357 6.00,1.00,.6262,.0262
358 7.00,1.00,.7664,.4929
359 8.00,1.00,.9065,1.3929
363 AT_SETUP([RANK all-ties due to tiny weights])
364 AT_DATA([rank.sps], [dnl
365 DATA LIST LIST NOTABLE /x * w *.
401 AT_CHECK([pspp -o pspp.csv rank.sps])
402 AT_CHECK([cat pspp.csv], [0], [dnl
403 Variables Created By RANK
409 Variables Created By RANK
415 Variables Created By RANK
421 Variables Created By RANK
425 x into Nx(NORMAL of x using VW)
429 1.00,.10,.000,.100,1.000,-1.938
430 2.00,.10,.100,.200,2.000,-1.412
431 3.00,.10,.200,.300,3.000,-1.119
432 4.00,.20,.300,.500,4.000,-.8046
433 5.00,.10,.500,.600,5.000,-.5549
434 6.00,.10,.600,.700,6.000,-.4067
435 7.00,.10,.700,.800,7.000,-.2670
436 8.00,.10,.800,.900,8.000,-.1323
440 AT_SETUP([RANK and TEMPORARY])
441 AT_DATA([rank.sps], [dnl
442 DATA LIST LIST NOTABLE /age (f2) gender (a1).
458 SELECT IF gender = 'm'.
459 RANK age /RANK INTO Rm.
462 SELECT IF gender = 'f'.
463 RANK age /RANK INTO Rf.
467 AT_CHECK([pspp -O format=csv rank.sps], [0], [dnl
468 Variables Created By RANK
472 age into Rm(RANK of age)
474 Variables Created By RANK
478 age into Rf(RANK of age)
496 AT_SETUP([RANK variable name fallback])
497 AT_DATA([rank.sps], [dnl
498 DATA LIST LIST NOTABLE /foo * rfoo * ran003 *.
517 AT_CHECK([pspp -o pspp.csv rank.sps])
518 AT_CHECK([cat pspp.csv], [0], [dnl
519 Variables Created By RANK
523 foo into RAN001(RANK of foo)
525 Variable,Description,Position
528 ran003,Format: F8.2,3
529 RAN001,"Label: RANK of foo
534 AT_SETUP([RANK robust variable name creation])
535 AT_DATA([rank.sps], [dnl
536 DATA LIST LIST notable /x * rx * ran001 TO ran999.
549 DELETE VAR ran001 TO ran999.
553 AT_CHECK([pspp -O format=csv rank.sps], [0], [dnl
554 "rank.sps:3: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
556 "rank.sps:4: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
558 "rank.sps:5: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
560 "rank.sps:6: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
562 "rank.sps:7: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
564 "rank.sps:8: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
566 "rank.sps:9: warning: Missing value(s) for all variables from rx onward. These will be filled with the system-missing value or blanks, as appropriate."
568 Variables Created By RANK
572 x into RNKRA01(RANK of x)
586 dnl Test for proper behaviour in the face of invalid input.
587 AT_SETUP([RANK handling of invalid input])
588 AT_DATA([rank.sps], [dnl
589 DATA LIST LIST NOTABLE /x * a (a2).
604 AT_CHECK([pspp -O format=csv --testing-mode rank.sps], [1], [dnl
605 Variables Created By RANK
611 rank.sps:14: error: RANK: DEBUG XFORM FAIL transformation executed
615 AT_SETUP([RANK handling of invalid syntax])
616 AT_DATA([rank.sps], [dnl
617 DATA LIST LIST NOTABLE /x * a (a2).
628 * invalid NTILES (no parameter)
633 * invalid NTILES (not an integer)
639 * destination variable already exists
644 * Too many variables in INTO
646 /RANK INTO foo bar wiz.
648 AT_CHECK([pspp -O format=csv rank.sps], [1], [dnl
649 rank.sps:15.1: error: RANK: Syntax error at end of command: expecting `@{:@'.
651 rank.sps:19.11: error: RANK: Syntax error at `d': expecting integer.
653 rank.sps:25: error: RANK: Variable x already exists.
655 rank.sps:30: error: RANK: Too many variables in INTO clause.