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)
137 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
138 a,1,,Scale,Input,8,Right,F8.2,F8.2,
139 b,2,,Scale,Input,8,Right,F8.2,F8.2,
140 Ra,3,RANK of a,Scale,Input,8,Right,F9.3,F9.3,
141 RFR001,4,RFRACTION of a,Scale,Input,8,Right,F6.4,F6.4,
142 count,5,N of a,Scale,Input,8,Right,F6.0,F6.0,
143 Rb,6,RANK of b,Scale,Input,8,Right,F9.3,F9.3,
144 RFR002,7,RFRACTION of b,Scale,Input,8,Right,F6.4,F6.4,
145 Nb,8,N of b,Scale,Input,8,Right,F6.0,F6.0,
148 a,b,Ra,RFR001,count,Rb,RFR002,Nb
149 .00,24.00,10.000,1.0000,10,8.000,.8889,9
150 1.00,32.00,9.000,.9000,10,4.000,.4444,9
151 2.00,31.00,8.000,.8000,10,5.000,.5556,9
152 2.00,32.00,8.000,.8000,10,4.000,.4444,9
153 4.00,30.00,6.000,.6000,10,6.000,.6667,9
154 5.00,29.00,5.000,.5000,10,7.000,.7778,9
155 6.00,1.00,4.000,.4000,10,9.000,1.0000,9
156 7.00,43.00,3.000,.3000,10,2.000,.2222,9
157 8.00,. ,2.000,.2000,10,. ,. ,.
158 9.00,45.00,1.000,.1000,10,1.000,.1111,9
162 AT_SETUP([RANK with SAVAGE, PERCENT, PROPORTION, NTILES])
163 AT_DATA([rank.sps], [dnl
164 DATA LIST LIST NOTABLE /a * b *.
190 AT_CHECK([pspp -o pspp.csv rank.sps])
191 AT_CHECK([cat pspp.csv], [0], [dnl
192 Variables Created By RANK
196 a into Sa(SAVAGE of a)
198 a into Pa(PERCENT of a)
200 a into PRO001(PROPORTION of a using BLOM)
202 a into Na(NTILES of a)
204 a into NOR001(NORMAL of a using BLOM)
207 a,b,Sa,Pa,PRO001,Na,NOR001
208 .00,24.00,-.9000,10.00,.0610,1,-1.547
209 1.00,32.00,-.7889,20.00,.1585,1,-1.000
210 2.00,31.00,-.5925,30.00,.2561,2,-.6554
211 2.00,32.00,-.5925,30.00,.2561,2,-.6554
212 4.00,30.00,-.3544,40.00,.3537,2,-.3755
213 5.00,29.00,-.1544,50.00,.4512,2,-.1226
214 6.00,1.00,.0956,60.00,.5488,3,.1226
215 7.00,43.00,.4290,70.00,.6463,3,.3755
216 8.00,8.00,.9290,80.00,.7439,3,.6554
217 9.00,45.00,1.9290,90.00,.8415,4,1.0005
221 AT_SETUP([RANK with SPLIT FILE])
222 AT_DATA([rank.sps], [dnl
223 DATA LIST LIST NOTABLE /a * g1 g2 *.
269 AT_CHECK([pspp -o pspp.csv rank.sps])
270 AT_CHECK([cat pspp.csv], [0], [dnl
271 Variables Created By RANK
275 a into Ra(RANK of a BY g2 g1)
277 a into Na(NORMAL of a using RANKIT BY g2 g1)
279 Variables Created By RANK
283 a into RAN001(RANK of a BY g2)
285 a into NOR001(NORMAL of a using RANKIT BY g2)
288 a,g1,g2,Ra,Na,RAN001,NOR001
289 2.00,1.00,2.00,8.000,.9674,4.000,.5244
290 2.00,1.00,2.00,8.000,.9674,4.000,.5244
291 3.00,1.00,2.00,7.000,.5895,3.000,.0000
292 4.00,1.00,2.00,6.000,.2822,2.000,-.5244
293 5.00,1.00,2.00,5.000,.0000,1.000,-1.282
294 1.00,.00,2.00,8.000,1.5341,8.000,1.5341
295 2.00,.00,2.00,7.000,.8871,7.000,.8871
296 3.00,.00,2.00,6.000,.4888,6.000,.4888
297 4.00,.00,2.00,5.000,.1573,5.000,.1573
298 5.00,.00,2.00,4.000,-.1573,4.000,-.1573
299 6.00,.00,2.00,3.000,-.4888,3.000,-.4888
300 7.00,.00,2.00,2.000,-.8871,2.000,-.8871
301 8.00,.00,2.00,1.000,-1.534,1.000,-1.534
302 6.00,1.00,2.00,4.000,-.2822,4.000,1.1503
303 7.00,1.00,2.00,2.000,-.9674,2.000,-.3186
304 7.00,1.00,2.00,2.000,-.9674,2.000,-.3186
305 8.00,1.00,2.00,1.000,-1.593,1.000,-1.150
306 9.00,1.00,1.00,1.000,.0000,1.000,.0000
310 # Also tests small ranks for special case of SAVAGE ranks.
311 AT_SETUP([RANK with fractional ranks])
312 AT_DATA([rank.sps], [dnl
313 DATA LIST LIST NOTABLE /a * w * .
335 AT_CHECK([pspp -o pspp.csv rank.sps])
336 AT_CHECK([cat pspp.csv], [0], [dnl
337 Variables Created By RANK
341 a into Pa(PROPORTION of a using TUKEY)
343 a into Sa(SAVAGE of a)
347 1.00,1.50,.1285,-.8016
348 2.00,.20,.1776,-.6905
349 3.00,.10,.1986,-.6905
350 4.00,1.00,.3458,-.5305
351 5.00,1.00,.4860,-.2905
352 6.00,1.00,.6262,.0262
353 7.00,1.00,.7664,.4929
354 8.00,1.00,.9065,1.3929
358 AT_SETUP([RANK all-ties due to tiny weights])
359 AT_DATA([rank.sps], [dnl
360 DATA LIST LIST NOTABLE /x * w *.
396 AT_CHECK([pspp -o pspp.csv rank.sps])
397 AT_CHECK([cat pspp.csv], [0], [dnl
398 Variables Created By RANK
404 Variables Created By RANK
410 Variables Created By RANK
416 Variables Created By RANK
420 x into Nx(NORMAL of x using VW)
424 1.00,.10,.000,.100,1.000,-1.938
425 2.00,.10,.100,.200,2.000,-1.412
426 3.00,.10,.200,.300,3.000,-1.119
427 4.00,.20,.300,.500,4.000,-.8046
428 5.00,.10,.500,.600,5.000,-.5549
429 6.00,.10,.600,.700,6.000,-.4067
430 7.00,.10,.700,.800,7.000,-.2670
431 8.00,.10,.800,.900,8.000,-.1323
435 AT_SETUP([RANK and TEMPORARY])
436 AT_DATA([rank.sps], [dnl
437 DATA LIST LIST NOTABLE /age (f2) gender (a1).
453 SELECT IF gender = 'm'.
454 RANK age /RANK INTO Rm.
457 SELECT IF gender = 'f'.
458 RANK age /RANK INTO Rf.
462 AT_CHECK([pspp -O format=csv rank.sps], [0], [dnl
463 Variables Created By RANK
467 age into Rm(RANK of age)
469 Variables Created By RANK
473 age into Rf(RANK of age)
491 AT_SETUP([RANK variable name fallback])
492 AT_DATA([rank.sps], [dnl
493 DATA LIST LIST NOTABLE /foo * rfoo * ran003 *.
512 AT_CHECK([pspp -o pspp.csv rank.sps])
513 AT_CHECK([cat pspp.csv], [0], [dnl
514 Variables Created By RANK
518 foo into RAN001(RANK of foo)
521 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
522 foo,1,,Scale,Input,8,Right,F8.2,F8.2,
523 rfoo,2,,Scale,Input,8,Right,F8.2,F8.2,
524 ran003,3,,Scale,Input,8,Right,F8.2,F8.2,
525 RAN001,4,RANK of foo,Scale,Input,8,Right,F9.3,F9.3,
529 AT_SETUP([RANK robust variable name creation])
530 AT_DATA([rank.sps], [dnl
531 DATA LIST LIST notable /x * rx * ran001 TO ran999.
544 DELETE VAR ran001 TO ran999.
548 AT_CHECK([pspp -O format=csv rank.sps], [0], [dnl
549 "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."
551 "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."
553 "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."
555 "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."
557 "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."
559 "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."
561 "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."
563 Variables Created By RANK
567 x into RNKRA01(RANK of x)
581 dnl Test for proper behaviour in the face of invalid input.
582 AT_SETUP([RANK handling of invalid input])
583 AT_DATA([rank.sps], [dnl
584 DATA LIST LIST NOTABLE /x * a (a2).
599 AT_CHECK([pspp -O format=csv --testing-mode rank.sps], [1], [dnl
600 Variables Created By RANK
606 rank.sps:14: error: RANK: DEBUG XFORM FAIL transformation executed
610 AT_SETUP([RANK handling of invalid syntax])
611 AT_DATA([rank.sps], [dnl
612 DATA LIST LIST NOTABLE /x * a (a2).
623 * invalid NTILES (no parameter)
628 * invalid NTILES (not an integer)
634 * destination variable already exists
639 * Too many variables in INTO
641 /RANK INTO foo bar wiz.
643 AT_CHECK([pspp -O format=csv rank.sps], [1], [dnl
644 rank.sps:15.1: error: RANK: Syntax error at end of command: expecting `@{:@'.
646 rank.sps:19.11: error: RANK: Syntax error at `d': expecting integer.
648 rank.sps:25: error: RANK: Variable x already exists.
650 rank.sps:30: error: RANK: Too many variables in INTO clause.