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.
40 DISPLAY VARIABLES/VARIABLES=a TO f.
42 AT_CHECK([pspp -O format=csv autorecode.sps], [0], [dnl
44 u,v,w,x,y,z,a,b,c,d,e,f
45 11,11,11,11,11,11,6.00,5.00,4.00,3.00,2.00,1.00
46 12,12,12,12,12,12,1.00,6.00,5.00,4.00,3.00,2.00
47 13,13,13,13,13,13,2.00,1.00,6.00,5.00,4.00,3.00
48 14,14,14,14,14,14,3.00,2.00,1.00,6.00,5.00,4.00
49 15,15,15,15,15,15,4.00,3.00,2.00,1.00,6.00,5.00
50 16,16,16,16,16,16,5.00,4.00,3.00,2.00,1.00,6.00
53 Name,Position,Print Format,Write Format,Missing Values
57 d,10,F8.2,F8.2,3 THRU 6
58 e,11,F8.2,F8.2,2 THRU 6
59 f,12,F8.2,F8.2,1 THRU 6
63 AT_SETUP([AUTORECODE numbers and short strings])
64 AT_DATA([autorecode.sps],
65 [data list /X 1-5(a) Y 7.
78 missing values x('asdfk') y(9).
80 autorecode x y into A B/descend.
87 AT_CHECK([pspp -O format=csv autorecode.sps], [0],
88 [Table: Reading 1 record from INLINE.
89 Variable,Record,Columns,Format
107 lasdj,1,1.00,2.00,.00,1.00
108 asdfk,0,4.00,3.00,.00,1.00
109 asdfj,2,3.00,1.00,1.00,2.00
110 asdfj,1,3.00,2.00,.00,1.00
111 asdfk,2,4.00,1.00,1.00,2.00
112 asdfj,9,3.00,4.00,. ,. @&t@
113 lajks,9,2.00,4.00,. ,. @&t@
114 asdfk,0,4.00,3.00,.00,1.00
115 asdfk,1,4.00,2.00,.00,1.00
121 AT_SETUP([AUTORECODE long strings and check the value labels])
123 [data list notable list /s (a16) x *.
134 variable labels s 'tracking my stuff'.
135 value labels /s 'thingummies' 'Funny sticky things'.
137 autorecode s into new.
141 display dictionary/variables=new.
144 AT_CHECK([pspp -O format=csv ar.sps], [0],
148 thingummies,2.00,3.00
152 thingummies,6.00,3.00
153 oojimiflips,7.00,2.00
156 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
157 new,3,tracking my stuff,Scale,Input,8,Right,F8.2,F8.2,
160 Variable Value,,Label
161 tracking my stuff,1.00,oojars
163 ,3.00,Funny sticky things
170 AT_SETUP([AUTORECODE group subcommand])
171 AT_DATA([ar-group.sps],
172 [data list notable list /x * y *.
182 missing values y (12).
189 display variables /variables=a b.
192 AT_CHECK([pspp -O format=csv ar-group.sps], [0],
195 11.00,10.00,2.00,1.00
196 12.00,12.00,8.00,8.00
197 13.00,15.00,3.00,5.00
198 14.00,11.00,4.00,2.00
199 15.00,12.00,5.00,8.00
200 16.00,18.00,6.00,7.00
203 Name,Position,Print Format,Write Format,Missing Values
212 AT_SETUP([AUTORECODE group - string variables])
213 AT_DATA([strings.sps],
214 [data list notable list /x (a8) y (a16).
224 autorecode x y into a b
227 delete variables x y.
233 AT_CHECK([pspp -O format=csv strings.sps], [0],
246 dnl Tests for a crash which happened when the /GROUP subcommand
247 dnl appeared with string variables of different widths.
248 AT_SETUP([AUTORECODE group vs. strings])
249 AT_DATA([ar-strings.sps],
250 [data list notable list /a (a12) b (a6).
258 autorecode a b into x y
264 AT_CHECK([pspp -O format=csv ar-strings.sps], [0],
270 three,eleven,7.00,1.00
271 four,nought,2.00,4.00
278 AT_SETUP([AUTORECODE /blank])
280 AT_DATA([auto-blank.sps], [dnl
281 data list notable list /x (a8) y * z (a16).
290 autorecode variables x y z into a b c /blank=missing.
295 AT_CHECK([pspp -O format=csv auto-blank.sps], [0], [dnl
307 dnl AUTORECODE had a use-after-free error when TEMPORARY was in use.
309 AT_SETUP([AUTORECODE with TEMPORARY])
310 AT_DATA([autorecode.sps],
311 [data list /X 1-5(a) Y 7.
326 autorecode x y into A B/descend.
329 AT_CHECK([pspp -O format=csv autorecode.sps], [0],
330 [Table: Reading 1 record from INLINE.
331 Variable,Record,Columns,Format
350 dnl For compatibility, make sure that /INTO (with leading slash) is accepted
352 AT_SETUP([AUTORECODE with /INTO])
353 AT_DATA([autorecode.sps],
354 [data list list notable /x .
365 autorecode x /into y.
369 AT_CHECK([pspp -O format=csv autorecode.sps], [0],