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([AUTORECODE procedure])
19 AT_SETUP([AUTORECODE multiple missing values])
20 AT_DATA([autorecode.sps],
21 [DATA LIST LIST NOTABLE /u v w x y z (F2.0).
38 AUTORECODE u v w x y z INTO a b c d e f/print.
40 DISPLAY VARIABLES/VARIABLES=a TO f.
42 AT_CHECK([pspp -O format=csv autorecode.sps], [0], [dnl
43 Table: Recoding u into a.
44 Old Value,New Value,Value Label
52 Table: Recoding v into b.
53 Old Value,New Value,Value Label
61 Table: Recoding w into c.
62 Old Value,New Value,Value Label
70 Table: Recoding x into d.
71 Old Value,New Value,Value Label
79 Table: Recoding y into e.
80 Old Value,New Value,Value Label
88 Table: Recoding z into f.
89 Old Value,New Value,Value Label
98 u,v,w,x,y,z,a,b,c,d,e,f
99 11,11,11,11,11,11,6,5,4,3,2,1
100 12,12,12,12,12,12,1,6,5,4,3,2
101 13,13,13,13,13,13,2,1,6,5,4,3
102 14,14,14,14,14,14,3,2,1,6,5,4
103 15,15,15,15,15,15,4,3,2,1,6,5
104 16,16,16,16,16,16,5,4,3,2,1,6
107 Name,Position,Print Format,Write Format,Missing Values
110 c,9,F1.0,F1.0,4; 5; 6
111 d,10,F1.0,F1.0,3 THRU 6
112 e,11,F1.0,F1.0,2 THRU 6
113 f,12,F1.0,F1.0,1 THRU 6
117 AT_SETUP([AUTORECODE numbers and short strings])
118 AT_DATA([autorecode.sps],
119 [data list /X 1-5(a) Y 7.
132 missing values x('asdfk') y(9).
134 autorecode x y into A B/descend/print.
137 compute Z=trunc(y/2).
142 AT_CHECK([pspp -O format=csv autorecode.sps], [0],
143 [Table: Reading 1 record from INLINE.
144 Variable,Record,Columns,Format
148 Table: Recoding X into A.
149 Old Value,New Value,Value Label
155 Table: Recoding Y into B.
156 Old Value,New Value,Value Label
188 AT_SETUP([AUTORECODE long strings and check the value labels])
190 [data list notable list /s (a16) x (f1.0).
201 variable labels s 'tracking my stuff'.
202 value labels /s 'thingummies' 'Funny sticky things'.
204 autorecode s into new/print.
208 display dictionary/variables=new.
211 AT_CHECK([pspp -O format=csv ar.sps], [0],
212 [Table: Recoding s into new (tracking my stuff).
213 Old Value,New Value,Value Label
215 oojimiflips,2,oojimiflips
216 thingummies,3,Funny sticky things
230 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format
231 new,3,tracking my stuff,Nominal,Input,8,Right,F1.0,F1.0
234 Variable Value,,Label
235 tracking my stuff,1,oojars
237 ,3,Funny sticky things
244 AT_SETUP([AUTORECODE group subcommand])
245 AT_DATA([ar-group.sps],
246 [data list notable list /x y (f8.0).
256 missing values y (12).
264 display variables /variables=a b.
267 AT_CHECK([pspp -O format=csv ar-group.sps], [0],
268 [Table: Recoding grouped variables.
269 Old Value,New Value,Value Label
289 Name,Position,Print Format,Write Format,Missing Values
298 AT_SETUP([AUTORECODE group - string variables])
299 AT_DATA([strings.sps],
300 [data list notable list /x (a8) y (a16).
310 autorecode x y into a b
314 delete variables x y.
319 AT_CHECK([pspp -O format=csv strings.sps], [0],
320 [Table: Recoding grouped variables.
321 Old Value,New Value,Value Label
343 dnl Tests for a crash which happened when the /GROUP subcommand
344 dnl appeared with string variables of different widths.
345 AT_SETUP([AUTORECODE group vs. strings])
346 AT_DATA([ar-strings.sps],
347 [data list notable list /a (a12) b (a6).
355 autorecode a b into x y
362 AT_CHECK([pspp -O format=csv ar-strings.sps], [0], [dnl
363 Table: Recoding grouped variables.
364 Old Value,New Value,Value Label
386 AT_SETUP([AUTORECODE /blank])
388 AT_DATA([auto-blank.sps], [dnl
389 data list notable list /x (a8) y (f8.0) z (a16).
398 autorecode variables x y z into a b c /blank=missing /print.
403 AT_CHECK([pspp -O format=csv auto-blank.sps], [0], [dnl
404 Table: Recoding x into a.
405 Old Value,New Value,Value Label
410 Table: Recoding y into b.
411 Old Value,New Value,Value Label
415 Table: Recoding z into c.
416 Old Value,New Value,Value Label
417 charliebrown,1,charliebrown
431 dnl AUTORECODE had a use-after-free error when TEMPORARY was in use.
433 AT_SETUP([AUTORECODE with TEMPORARY])
434 AT_DATA([autorecode.sps],
435 [data list /X 1-5(a) Y 7.
450 autorecode x y into A B/descend/print.
453 AT_CHECK([pspp -O format=csv autorecode.sps], [0], [dnl
454 Table: Reading 1 record from INLINE.
455 Variable,Record,Columns,Format
459 Table: Recoding X into A.
460 Old Value,New Value,Value Label
465 Table: Recoding Y into B.
466 Old Value,New Value,Value Label
485 dnl For compatibility, make sure that /INTO (with leading slash) is accepted
487 AT_SETUP([AUTORECODE with /INTO])
488 AT_DATA([autorecode.sps],
489 [data list list notable /x (f8.0).
500 autorecode x /into y /print.
504 AT_CHECK([pspp -O format=csv autorecode.sps], [0],
505 [Table: Recoding x into y.
506 Old Value,New Value,Value Label
526 AT_SETUP([AUTORECODE with /BLANK without specifier])
528 AT_DATA([autorecode.sps], [data list notable list /x (a18).
535 * /BLANK should be either =MISSING or =VALID
542 AT_CHECK([pspp -O format=csv autorecode.sps], [1], [ignore])