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 Table: Variables Created by RANK
39 Existing Variable,New Variable,Function
54 # This checks for regression against a crash reported as bug #38482
55 # that occurred when multiple variables were specified without any
56 # rank specifications.
57 AT_SETUP([RANK multiple variables with defaults])
58 AT_DATA([rank.sps], [dnl
59 DATA LIST LIST NOTABLE /x * y * z *.
69 AT_CHECK([pspp -o pspp.csv rank.sps])
70 AT_CHECK([cat pspp.csv], [0], [dnl
71 Table: Variables Created by RANK
72 Existing Variable,New Variable,Function
79 1.00,2.00,3.00,1.000,1.000,1.000
80 4.00,5.00,6.00,2.000,2.000,2.000
84 AT_SETUP([RANK with RANK, RFRACTION, N])
85 AT_DATA([rank.sps], [dnl
86 DATA LIST LIST NOTABLE /a * b *.
112 AT_CHECK([pspp -o pspp.csv rank.sps])
113 AT_CHECK([cat pspp.csv], [0], [dnl
114 Table: Variables Created by RANK
115 Existing Variable,New Variable,Function
124 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
125 a,1,,Scale,Input,8,Right,F8.2,F8.2,
126 b,2,,Scale,Input,8,Right,F8.2,F8.2,
127 Ra,3,RANK of a,Scale,Input,8,Right,F9.3,F9.3,
128 RFR001,4,RFRACTION of a,Scale,Input,8,Right,F6.4,F6.4,
129 count,5,N of a,Scale,Input,8,Right,F6.0,F6.0,
130 Rb,6,RANK of b,Scale,Input,8,Right,F9.3,F9.3,
131 RFR002,7,RFRACTION of b,Scale,Input,8,Right,F6.4,F6.4,
132 Nb,8,N of b,Scale,Input,8,Right,F6.0,F6.0,
135 a,b,Ra,RFR001,count,Rb,RFR002,Nb
136 .00,24.00,10.000,1.0000,10,8.000,.8889,9
137 1.00,32.00,9.000,.9000,10,4.000,.4444,9
138 2.00,31.00,8.000,.8000,10,5.000,.5556,9
139 2.00,32.00,8.000,.8000,10,4.000,.4444,9
140 4.00,30.00,6.000,.6000,10,6.000,.6667,9
141 5.00,29.00,5.000,.5000,10,7.000,.7778,9
142 6.00,1.00,4.000,.4000,10,9.000,1.0000,9
143 7.00,43.00,3.000,.3000,10,2.000,.2222,9
144 8.00,. ,2.000,.2000,10,. ,. ,.
145 9.00,45.00,1.000,.1000,10,1.000,.1111,9
149 AT_SETUP([RANK with SAVAGE, PERCENT, PROPORTION, NTILES])
150 AT_DATA([rank.sps], [dnl
151 DATA LIST LIST NOTABLE /a * b *.
177 AT_CHECK([pspp -o pspp.csv rank.sps])
178 AT_CHECK([cat pspp.csv], [0], [dnl
179 Table: Variables Created by RANK
180 Existing Variable,New Variable,Function,Fraction
183 a,PRO001,PROPORTION,BLOM
188 a,b,Sa,Pa,PRO001,Na,NOR001
189 .00,24.00,-.9000,10.00,.0610,1,-1.547
190 1.00,32.00,-.7889,20.00,.1585,1,-1.000
191 2.00,31.00,-.5925,30.00,.2561,2,-.6554
192 2.00,32.00,-.5925,30.00,.2561,2,-.6554
193 4.00,30.00,-.3544,40.00,.3537,2,-.3755
194 5.00,29.00,-.1544,50.00,.4512,2,-.1226
195 6.00,1.00,.0956,60.00,.5488,3,.1226
196 7.00,43.00,.4290,70.00,.6463,3,.3755
197 8.00,8.00,.9290,80.00,.7439,3,.6554
198 9.00,45.00,1.9290,90.00,.8415,4,1.0005
202 AT_SETUP([RANK with SPLIT FILE])
203 AT_DATA([rank.sps], [dnl
204 DATA LIST LIST NOTABLE /a * g1 g2 *.
250 AT_CHECK([pspp -o pspp.csv rank.sps])
251 AT_CHECK([cat pspp.csv], [0], [dnl
252 Table: Variables Created by RANK
253 Existing Variable,New Variable,Function,Fraction,Grouping Variables
255 a,Na,NORMAL,RANKIT,g2 g1
257 Table: Variables Created by RANK
258 Existing Variable,New Variable,Function,Fraction,Grouping Variables
260 a,NOR001,NORMAL,RANKIT,g2
263 a,g1,g2,Ra,Na,RAN001,NOR001
264 2.00,1.00,2.00,8.000,.9674,4.000,.5244
265 2.00,1.00,2.00,8.000,.9674,4.000,.5244
266 3.00,1.00,2.00,7.000,.5895,3.000,.0000
267 4.00,1.00,2.00,6.000,.2822,2.000,-.5244
268 5.00,1.00,2.00,5.000,.0000,1.000,-1.282
269 1.00,.00,2.00,8.000,1.5341,8.000,1.5341
270 2.00,.00,2.00,7.000,.8871,7.000,.8871
271 3.00,.00,2.00,6.000,.4888,6.000,.4888
272 4.00,.00,2.00,5.000,.1573,5.000,.1573
273 5.00,.00,2.00,4.000,-.1573,4.000,-.1573
274 6.00,.00,2.00,3.000,-.4888,3.000,-.4888
275 7.00,.00,2.00,2.000,-.8871,2.000,-.8871
276 8.00,.00,2.00,1.000,-1.534,1.000,-1.534
277 6.00,1.00,2.00,4.000,-.2822,4.000,1.1503
278 7.00,1.00,2.00,2.000,-.9674,2.000,-.3186
279 7.00,1.00,2.00,2.000,-.9674,2.000,-.3186
280 8.00,1.00,2.00,1.000,-1.593,1.000,-1.150
281 9.00,1.00,1.00,1.000,.0000,1.000,.0000
285 # Also tests small ranks for special case of SAVAGE ranks.
286 AT_SETUP([RANK with fractional ranks])
287 AT_DATA([rank.sps], [dnl
288 DATA LIST LIST NOTABLE /a * w * .
310 AT_CHECK([pspp -o pspp.csv rank.sps])
311 AT_CHECK([cat pspp.csv], [0], [dnl
312 Table: Variables Created by RANK
313 Existing Variable,New Variable,Function,Fraction
314 a,Pa,PROPORTION,TUKEY
319 1.00,1.50,.1285,-.8016
320 2.00,.20,.1776,-.6905
321 3.00,.10,.1986,-.6905
322 4.00,1.00,.3458,-.5305
323 5.00,1.00,.4860,-.2905
324 6.00,1.00,.6262,.0262
325 7.00,1.00,.7664,.4929
326 8.00,1.00,.9065,1.3929
330 AT_SETUP([RANK all-ties due to tiny weights])
331 AT_DATA([rank.sps], [dnl
332 DATA LIST LIST NOTABLE /x * w *.
368 AT_CHECK([pspp -o pspp.csv rank.sps])
369 AT_CHECK([cat pspp.csv], [0], [dnl
370 Table: Variables Created by RANK
371 Existing Variable,New Variable,Function
374 Table: Variables Created by RANK
375 Existing Variable,New Variable,Function
378 Table: Variables Created by RANK
379 Existing Variable,New Variable,Function
382 Table: Variables Created by RANK
383 Existing Variable,New Variable,Function,Fraction
388 1.00,.10,.000,.100,1.000,-1.938
389 2.00,.10,.100,.200,2.000,-1.412
390 3.00,.10,.200,.300,3.000,-1.119
391 4.00,.20,.300,.500,4.000,-.8046
392 5.00,.10,.500,.600,5.000,-.5549
393 6.00,.10,.600,.700,6.000,-.4067
394 7.00,.10,.700,.800,7.000,-.2670
395 8.00,.10,.800,.900,8.000,-.1323
399 AT_SETUP([RANK and TEMPORARY])
400 AT_DATA([rank.sps], [dnl
401 DATA LIST LIST NOTABLE /age (f2) gender (a1).
417 SELECT IF gender = 'm'.
418 RANK age /RANK INTO Rm.
421 SELECT IF gender = 'f'.
422 RANK age /RANK INTO Rf.
426 AT_CHECK([pspp -O format=csv rank.sps], [0], [dnl
427 Table: Variables Created by RANK
428 Existing Variable,New Variable,Function
431 Table: Variables Created by RANK
432 Existing Variable,New Variable,Function
451 AT_SETUP([RANK variable name fallback])
452 AT_DATA([rank.sps], [dnl
453 DATA LIST LIST NOTABLE /foo * rfoo * ran003 *.
472 AT_CHECK([pspp -o pspp.csv rank.sps])
473 AT_CHECK([cat pspp.csv], [0], [dnl
474 Table: Variables Created by RANK
475 Existing Variable,New Variable,Function
479 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
480 foo,1,,Scale,Input,8,Right,F8.2,F8.2,
481 rfoo,2,,Scale,Input,8,Right,F8.2,F8.2,
482 ran003,3,,Scale,Input,8,Right,F8.2,F8.2,
483 RAN001,4,RANK of foo,Scale,Input,8,Right,F9.3,F9.3,
487 AT_SETUP([RANK robust variable name creation])
488 AT_DATA([rank.sps], [dnl
489 DATA LIST LIST notable /x * rx * ran001 TO ran999.
502 DELETE VAR ran001 TO ran999.
506 AT_CHECK([pspp -O format=csv rank.sps], [0], [dnl
507 "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."
509 "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."
511 "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."
513 "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."
515 "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."
517 "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."
519 "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."
521 Table: Variables Created by RANK
522 Existing Variable,New Variable,Function
537 dnl Test for proper behaviour in the face of invalid input.
538 AT_SETUP([RANK handling of invalid input])
539 AT_DATA([rank.sps], [dnl
540 DATA LIST LIST NOTABLE /x * a (a2).
555 AT_CHECK([pspp -O format=csv --testing-mode rank.sps], [1], [dnl
556 Table: Variables Created by RANK
557 Existing Variable,New Variable,Function
560 rank.sps:14: error: RANK: DEBUG XFORM FAIL transformation executed
564 AT_SETUP([RANK handling of invalid syntax])
565 AT_DATA([rank.sps], [dnl
566 DATA LIST LIST NOTABLE /x * a (a2).
577 * invalid NTILES (no parameter)
582 * invalid NTILES (not an integer)
588 * destination variable already exists
593 * Too many variables in INTO
595 /RANK INTO foo bar wiz.
597 AT_CHECK([pspp -O format=csv rank.sps], [1], [dnl
598 rank.sps:15.1: error: RANK: Syntax error at end of command: expecting `@{:@'.
600 rank.sps:19.11: error: RANK: Syntax error at `d': expecting integer.
602 rank.sps:25: error: RANK: Variable x already exists.
604 rank.sps:30: error: RANK: Too many variables in INTO clause.