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/>.
18 AT_SETUP([RANK simple case with defaults])
19 AT_DATA([rank.sps], [dnl
20 DATA LIST LIST NOTABLE /x (f8).
35 AT_CHECK([pspp -o pspp.csv rank.sps])
36 AT_CHECK([cat pspp.csv], [0], [dnl
37 Variables Created By RANK
55 # This checks for regression against a crash reported as bug #38482
56 # that occurred when multiple variables were specified without any
57 # rank specifications.
58 AT_SETUP([RANK multiple variables with defaults])
59 AT_DATA([rank.sps], [dnl
60 DATA LIST LIST NOTABLE /x * y * z *.
70 AT_CHECK([pspp -o pspp.csv rank.sps])
71 AT_CHECK([cat pspp.csv], [0], [dnl
72 Variables Created By RANK
84 1.00,2.00,3.00,1.000,1.000,1.000
85 4.00,5.00,6.00,2.000,2.000,2.000
89 AT_SETUP([RANK with RANK, RFRACTION, N])
90 AT_DATA([rank.sps], [dnl
91 DATA LIST LIST NOTABLE /a * b *.
117 AT_CHECK([pspp -o pspp.csv rank.sps])
118 AT_CHECK([cat pspp.csv], [0], [dnl
119 Variables Created By RANK
127 a into RFR001(RFRACTION of a)
129 b into RFR002(RFRACTION of b)
135 Variable,Description,Position
140 RFR001,"Label: RFRACTION of a
146 RFR002,"Label: RFRACTION of b
152 a,b,Ra,RFR001,count,Rb,RFR002,Nb
153 .00,24.00,10.000,1.0000,10,8.000,.8889,9
154 1.00,32.00,9.000,.9000,10,4.000,.4444,9
155 2.00,31.00,8.000,.8000,10,5.000,.5556,9
156 2.00,32.00,8.000,.8000,10,4.000,.4444,9
157 4.00,30.00,6.000,.6000,10,6.000,.6667,9
158 5.00,29.00,5.000,.5000,10,7.000,.7778,9
159 6.00,1.00,4.000,.4000,10,9.000,1.0000,9
160 7.00,43.00,3.000,.3000,10,2.000,.2222,9
161 8.00,. ,2.000,.2000,10,. ,. ,.
162 9.00,45.00,1.000,.1000,10,1.000,.1111,9
166 AT_SETUP([RANK with SAVAGE, PERCENT, PROPORTION, NTILES])
167 AT_DATA([rank.sps], [dnl
168 DATA LIST LIST NOTABLE /a * b *.
194 AT_CHECK([pspp -o pspp.csv rank.sps])
195 AT_CHECK([cat pspp.csv], [0], [dnl
196 Variables Created By RANK
200 a into Sa(SAVAGE of a)
202 a into Pa(PERCENT of a)
204 a into PRO001(PROPORTION of a using BLOM)
206 a into Na(NTILES of a)
208 a into NOR001(NORMAL of a using BLOM)
211 a,b,Sa,Pa,PRO001,Na,NOR001
212 .00,24.00,-.9000,10.00,.0610,1,-1.547
213 1.00,32.00,-.7889,20.00,.1585,1,-1.000
214 2.00,31.00,-.5925,30.00,.2561,2,-.6554
215 2.00,32.00,-.5925,30.00,.2561,2,-.6554
216 4.00,30.00,-.3544,40.00,.3537,2,-.3755
217 5.00,29.00,-.1544,50.00,.4512,2,-.1226
218 6.00,1.00,.0956,60.00,.5488,3,.1226
219 7.00,43.00,.4290,70.00,.6463,3,.3755
220 8.00,8.00,.9290,80.00,.7439,3,.6554
221 9.00,45.00,1.9290,90.00,.8415,4,1.0005
225 AT_SETUP([RANK with SPLIT FILE])
226 AT_DATA([rank.sps], [dnl
227 DATA LIST LIST NOTABLE /a * g1 g2 *.
273 AT_CHECK([pspp -o pspp.csv rank.sps])
274 AT_CHECK([cat pspp.csv], [0], [dnl
275 Variables Created By RANK
279 a into Ra(RANK of a BY g2 g1)
281 a into Na(NORMAL of a using RANKIT BY g2 g1)
283 Variables Created By RANK
287 a into RAN001(RANK of a BY g2)
289 a into NOR001(NORMAL of a using RANKIT BY g2)
292 a,g1,g2,Ra,Na,RAN001,NOR001
293 2.00,1.00,2.00,8.000,.9674,4.000,.5244
294 2.00,1.00,2.00,8.000,.9674,4.000,.5244
295 3.00,1.00,2.00,7.000,.5895,3.000,.0000
296 4.00,1.00,2.00,6.000,.2822,2.000,-.5244
297 5.00,1.00,2.00,5.000,.0000,1.000,-1.282
298 1.00,.00,2.00,8.000,1.5341,8.000,1.5341
299 2.00,.00,2.00,7.000,.8871,7.000,.8871
300 3.00,.00,2.00,6.000,.4888,6.000,.4888
301 4.00,.00,2.00,5.000,.1573,5.000,.1573
302 5.00,.00,2.00,4.000,-.1573,4.000,-.1573
303 6.00,.00,2.00,3.000,-.4888,3.000,-.4888
304 7.00,.00,2.00,2.000,-.8871,2.000,-.8871
305 8.00,.00,2.00,1.000,-1.534,1.000,-1.534
306 6.00,1.00,2.00,4.000,-.2822,4.000,1.1503
307 7.00,1.00,2.00,2.000,-.9674,2.000,-.3186
308 7.00,1.00,2.00,2.000,-.9674,2.000,-.3186
309 8.00,1.00,2.00,1.000,-1.593,1.000,-1.150
310 9.00,1.00,1.00,1.000,.0000,1.000,.0000
314 # Also tests small ranks for special case of SAVAGE ranks.
315 AT_SETUP([RANK with fractional ranks])
316 AT_DATA([rank.sps], [dnl
317 DATA LIST LIST NOTABLE /a * w * .
339 AT_CHECK([pspp -o pspp.csv rank.sps])
340 AT_CHECK([cat pspp.csv], [0], [dnl
341 Variables Created By RANK
345 a into Pa(PROPORTION of a using TUKEY)
347 a into Sa(SAVAGE of a)
351 1.00,1.50,.1285,-.8016
352 2.00,.20,.1776,-.6905
353 3.00,.10,.1986,-.6905
354 4.00,1.00,.3458,-.5305
355 5.00,1.00,.4860,-.2905
356 6.00,1.00,.6262,.0262
357 7.00,1.00,.7664,.4929
358 8.00,1.00,.9065,1.3929
362 AT_SETUP([RANK all-ties due to tiny weights])
363 AT_DATA([rank.sps], [dnl
364 DATA LIST LIST NOTABLE /x * w *.
400 AT_CHECK([pspp -o pspp.csv rank.sps])
401 AT_CHECK([cat pspp.csv], [0], [dnl
402 Variables Created By RANK
408 Variables Created By RANK
414 Variables Created By RANK
420 Variables Created By RANK
424 x into Nx(NORMAL of x using VW)
428 1.00,.10,.000,.100,1.000,-1.938
429 2.00,.10,.100,.200,2.000,-1.412
430 3.00,.10,.200,.300,3.000,-1.119
431 4.00,.20,.300,.500,4.000,-.8046
432 5.00,.10,.500,.600,5.000,-.5549
433 6.00,.10,.600,.700,6.000,-.4067
434 7.00,.10,.700,.800,7.000,-.2670
435 8.00,.10,.800,.900,8.000,-.1323
439 AT_SETUP([RANK and TEMPORARY])
440 AT_DATA([rank.sps], [dnl
441 DATA LIST LIST NOTABLE /age (f2) gender (a1).
457 SELECT IF gender = 'm'.
458 RANK age /RANK INTO Rm.
461 SELECT IF gender = 'f'.
462 RANK age /RANK INTO Rf.
466 AT_CHECK([pspp -O format=csv rank.sps], [0], [dnl
467 Variables Created By RANK
471 age into Rm(RANK of age)
473 Variables Created By RANK
477 age into Rf(RANK of age)
495 AT_SETUP([RANK variable name fallback])
496 AT_DATA([rank.sps], [dnl
497 DATA LIST LIST NOTABLE /foo * rfoo * ran003 *.
516 AT_CHECK([pspp -o pspp.csv rank.sps])
517 AT_CHECK([cat pspp.csv], [0], [dnl
518 Variables Created By RANK
522 foo into RAN001(RANK of foo)
524 Variable,Description,Position
527 ran003,Format: F8.2,3
528 RAN001,"Label: RANK of foo
533 AT_SETUP([RANK robust variable name creation])
534 AT_DATA([rank.sps], [dnl
535 DATA LIST LIST notable /x * rx * ran001 TO ran999.
548 DELETE VAR ran001 TO ran999.
552 AT_CHECK([pspp -O format=csv rank.sps], [0], [dnl
553 "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."
555 "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."
557 "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."
559 "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."
561 "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."
563 "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."
565 "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."
567 Variables Created By RANK
571 x into RNKRA01(RANK of x)
585 dnl Test for proper behaviour in the face of invalid input.
586 AT_SETUP([RANK handling of invalid input])
587 AT_DATA([rank.sps], [dnl
588 DATA LIST LIST NOTABLE /x * a (a2).
603 AT_CHECK([pspp -O format=csv --testing-mode rank.sps], [1], [dnl
604 Variables Created By RANK
610 rank.sps:14: error: RANK: DEBUG XFORM FAIL transformation executed
614 AT_SETUP([RANK handling of invalid syntax])
615 AT_DATA([rank.sps], [dnl
616 DATA LIST LIST NOTABLE /x * a (a2).
627 * invalid NTILES (no parameter)
632 * invalid NTILES (not an integer)
638 * destination variable already exists
643 * Too many variables in INTO
645 /RANK INTO foo bar wiz.
647 AT_CHECK([pspp -O format=csv rank.sps], [1], [dnl
648 rank.sps:15.1: error: RANK: Syntax error at end of command: expecting `@{:@'.
650 rank.sps:19.11: error: RANK: Syntax error at `d': expecting integer.
652 rank.sps:25: error: RANK: Variable x already exists.
654 rank.sps:30: error: RANK: Too many variables in INTO clause.