SYSFILE INFO: Improve output formatting by using nested tables.
[pspp] / tests / language / stats / autorecode.at
1 AT_BANNER([AUTORECODE procedure])
2
3 AT_SETUP([AUTORECODE numbers and short strings])
4 AT_DATA([autorecode.sps],
5   [data list /X 1-5(a) Y 7.
6 begin data.
7 lasdj 1
8 asdfk 0
9 asdfj 2
10 asdfj 1
11 asdfk 2
12 asdfj 9
13 lajks 9
14 asdfk 0
15 asdfk 1
16 end data.
17
18 autorecode x y into A B/descend.
19
20 list.
21 compute Z=trunc(y/2).
22 autorecode z into W.
23 list.
24 ])
25 AT_CHECK([pspp -O format=csv autorecode.sps], [0],
26   [Table: Reading 1 record from INLINE.
27 Variable,Record,Columns,Format
28 X,1,1-  5,A5
29 Y,1,7-  7,F1.0
30
31 Table: Data List
32 X,Y,A,B
33 lasdj,1,1.00,3.00
34 asdfk,0,3.00,4.00
35 asdfj,2,4.00,2.00
36 asdfj,1,4.00,3.00
37 asdfk,2,3.00,2.00
38 asdfj,9,4.00,1.00
39 lajks,9,2.00,1.00
40 asdfk,0,3.00,4.00
41 asdfk,1,3.00,3.00
42
43 Table: Data List
44 X,Y,A,B,Z,W
45 lasdj,1,1.00,3.00,.00,1.00
46 asdfk,0,3.00,4.00,.00,1.00
47 asdfj,2,4.00,2.00,1.00,2.00
48 asdfj,1,4.00,3.00,.00,1.00
49 asdfk,2,3.00,2.00,1.00,2.00
50 asdfj,9,4.00,1.00,4.00,3.00
51 lajks,9,2.00,1.00,4.00,3.00
52 asdfk,0,3.00,4.00,.00,1.00
53 asdfk,1,3.00,3.00,.00,1.00
54 ])
55 AT_CLEANUP
56
57
58
59 AT_SETUP([AUTORECODE long strings and check the value labels])
60 AT_DATA([ar.sps],
61   [data list notable list /s (a16) x *.
62 begin data.
63 widgets      1
64 thingummies  2
65 oojars       3
66 widgets      4
67 oojars       5
68 thingummies  6
69 oojimiflips  7
70 end data.
71
72 autorecode s into new.
73
74 list.
75
76 display dictionary.
77 ])
78
79 AT_CHECK([pspp -O format=csv ar.sps], [0],
80   [Table: Data List
81 s,x,new
82 widgets         ,1.00,4.00
83 thingummies     ,2.00,3.00
84 oojars          ,3.00,1.00
85 widgets         ,4.00,4.00
86 oojars          ,5.00,1.00
87 thingummies     ,6.00,3.00
88 oojimiflips     ,7.00,2.00
89
90 Variable,Description,Position
91 s,Format: A16,1
92 x,Format: F8.2,2
93 new,"Format: F8.2
94
95 Value,Label
96 1.00,oojars
97 2.00,oojimiflips
98 3.00,thingummies
99 4.00,widgets",3
100 ])
101
102 AT_CLEANUP
103
104
105 AT_SETUP([AUTORECODE group subcommand])
106 AT_DATA([ar-group.sps],
107 [data list notable list /x * y *.
108 begin data.
109 11 10
110 12 12 
111 13 15
112 14 11
113 15 12
114 16 18
115 end data.
116
117 autorecode 
118         x y into a b
119         /group.
120
121 list.
122 ])
123
124 AT_CHECK([pspp -O format=csv ar-group.sps], [0],
125 [Table: Data List
126 x,y,a,b
127 11.00,10.00,2.00,1.00
128 12.00,12.00,3.00,3.00
129 13.00,15.00,4.00,6.00
130 14.00,11.00,5.00,2.00
131 15.00,12.00,6.00,3.00
132 16.00,18.00,7.00,8.00
133 ])
134
135 AT_CLEANUP
136
137
138
139 AT_SETUP([AUTORECODE group - string variables])
140 AT_DATA([strings.sps],
141 [data list notable list /x (a8) y (a16).
142 begin data.
143 fred bert
144 charlie "         "
145 delta echo
146 "      " windows
147 " "  nothing
148 end data.
149
150
151 autorecode x y into a b
152         /group.
153
154 delete variables x y.
155
156 list.
157
158 ])
159
160 AT_CHECK([pspp -O format=csv strings.sps], [0],
161 [Table: Data List
162 a,b
163 7.00,3.00
164 4.00,1.00
165 5.00,6.00
166 2.00,9.00
167 2.00,8.00
168 ])
169
170 AT_CLEANUP
171
172
173 dnl Tests for a crash which happened when the /GROUP subcommand
174 dnl appeared with string variables of different widths.
175 AT_SETUP([AUTORECODE group vs. strings])
176 AT_DATA([ar-strings.sps],
177   [data list notable list /a (a12) b (a6).
178 begin data.
179 one    nine
180 two    ten
181 three  eleven 
182 four   nought
183 end data.
184
185 autorecode a b into x y 
186         /group.
187
188 list.
189 ])
190
191 AT_CHECK([pspp -O format=csv ar-strings.sps], [0],
192 [dnl
193 Table: Data List
194 a,b,x,y
195 one         ,nine  ,5.00,3.00
196 two         ,ten   ,8.00,6.00
197 three       ,eleven,7.00,1.00
198 four        ,nought,2.00,4.00
199 ])
200
201 AT_CLEANUP
202
203
204
205 AT_SETUP([AUTORECODE /blank])
206
207 AT_DATA([auto-blank.sps],  [dnl
208 data list notable list /x (a8) y * z (a16).
209 begin data.
210 one   2  fred
211 two   4  ""
212 ""    4  fred
213 ""    2  charliebrown
214 three 2  charliebrown
215 end data.
216
217 autorecode variables x y z into a b c  /blank=missing.
218
219 list a b c y.
220 ])
221
222 AT_CHECK([pspp -O format=csv auto-blank.sps], [0], [dnl
223 Table: Data List
224 a,b,c,y
225 1.00,1.00,2.00,2.00
226 3.00,2.00,.  ,4.00
227 .  ,2.00,2.00,4.00
228 .  ,1.00,1.00,2.00
229 2.00,1.00,1.00,2.00
230 ])
231
232 AT_CLEANUP
233
234 dnl AUTORECODE had a use-after-free error when TEMPORARY was in use.
235 dnl Bug #32757.
236 AT_SETUP([AUTORECODE with TEMPORARY])
237 AT_DATA([autorecode.sps],
238   [data list /X 1-5(a) Y 7.
239 begin data.
240 lasdj 1
241 asdfk 0
242 asdfj 2
243 asdfj 1
244 asdfk 2
245 asdfj 9
246 lajks 9
247 asdfk 0
248 asdfk 1
249 end data.
250
251 temporary.
252 select if y > 1.
253 autorecode x y into A B/descend.
254 list.
255 ])
256 AT_CHECK([pspp -O format=csv autorecode.sps], [0],
257   [Table: Reading 1 record from INLINE.
258 Variable,Record,Columns,Format
259 X,1,1-  5,A5
260 Y,1,7-  7,F1.0
261
262 Table: Data List
263 X,Y,A,B
264 lasdj,1,.  ,.  @&t@
265 asdfk,0,2.00,.  @&t@
266 asdfj,2,3.00,2.00
267 asdfj,1,3.00,.  @&t@
268 asdfk,2,2.00,2.00
269 asdfj,9,3.00,1.00
270 lajks,9,1.00,1.00
271 asdfk,0,2.00,.  @&t@
272 asdfk,1,2.00,.  @&t@
273 ])
274 AT_CLEANUP