File: autorecode.at

package info (click to toggle)
pspp 0.8.4-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 35,692 kB
  • ctags: 20,600
  • sloc: ansic: 218,288; sh: 12,890; xml: 11,342; perl: 715; lisp: 597; makefile: 157
file content (274 lines) | stat: -rw-r--r-- 4,295 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
AT_BANNER([AUTORECODE procedure])

AT_SETUP([AUTORECODE numbers and short strings])
AT_DATA([autorecode.sps],
  [data list /X 1-5(a) Y 7.
begin data.
lasdj 1
asdfk 0
asdfj 2
asdfj 1
asdfk 2
asdfj 9
lajks 9
asdfk 0
asdfk 1
end data.

autorecode x y into A B/descend.

list.
compute Z=trunc(y/2).
autorecode z into W.
list.
])
AT_CHECK([pspp -O format=csv autorecode.sps], [0],
  [Table: Reading 1 record from INLINE.
Variable,Record,Columns,Format
X,1,1-  5,A5
Y,1,7-  7,F1.0

Table: Data List
X,Y,A,B
lasdj,1,1.00,3.00
asdfk,0,3.00,4.00
asdfj,2,4.00,2.00
asdfj,1,4.00,3.00
asdfk,2,3.00,2.00
asdfj,9,4.00,1.00
lajks,9,2.00,1.00
asdfk,0,3.00,4.00
asdfk,1,3.00,3.00

Table: Data List
X,Y,A,B,Z,W
lasdj,1,1.00,3.00,.00,1.00
asdfk,0,3.00,4.00,.00,1.00
asdfj,2,4.00,2.00,1.00,2.00
asdfj,1,4.00,3.00,.00,1.00
asdfk,2,3.00,2.00,1.00,2.00
asdfj,9,4.00,1.00,4.00,3.00
lajks,9,2.00,1.00,4.00,3.00
asdfk,0,3.00,4.00,.00,1.00
asdfk,1,3.00,3.00,.00,1.00
])
AT_CLEANUP



AT_SETUP([AUTORECODE long strings and check the value labels])
AT_DATA([ar.sps],
  [data list notable list /s (a16) x *.
begin data.
widgets      1
thingummies  2
oojars       3
widgets      4
oojars       5
thingummies  6
oojimiflips  7
end data.

autorecode s into new.

list.

display dictionary.
])

AT_CHECK([pspp -O format=csv ar.sps], [0],
  [Table: Data List
s,x,new
widgets         ,1.00,4.00
thingummies     ,2.00,3.00
oojars          ,3.00,1.00
widgets         ,4.00,4.00
oojars          ,5.00,1.00
thingummies     ,6.00,3.00
oojimiflips     ,7.00,2.00

Variable,Description,Position
s,Format: A16,1
x,Format: F8.2,2
new,"Format: F8.2

Value,Label
1.00,oojars
2.00,oojimiflips
3.00,thingummies
4.00,widgets",3
])

AT_CLEANUP


AT_SETUP([AUTORECODE group subcommand])
AT_DATA([ar-group.sps],
[data list notable list /x * y *.
begin data.
11 10
12 12 
13 15
14 11
15 12
16 18
end data.

autorecode 
	x y into a b
	/group.

list.
])

AT_CHECK([pspp -O format=csv ar-group.sps], [0],
[Table: Data List
x,y,a,b
11.00,10.00,2.00,1.00
12.00,12.00,3.00,3.00
13.00,15.00,4.00,6.00
14.00,11.00,5.00,2.00
15.00,12.00,6.00,3.00
16.00,18.00,7.00,8.00
])

AT_CLEANUP



AT_SETUP([AUTORECODE group - string variables])
AT_DATA([strings.sps],
[data list notable list /x (a8) y (a16).
begin data.
fred bert
charlie "         "
delta echo
"      " windows
" "  nothing
end data.


autorecode x y into a b
	/group.

delete variables x y.

list.

])

AT_CHECK([pspp -O format=csv strings.sps], [0],
[Table: Data List
a,b
7.00,3.00
4.00,1.00
5.00,6.00
2.00,9.00
2.00,8.00
])

AT_CLEANUP


dnl Tests for a crash which happened when the /GROUP subcommand
dnl appeared with string variables of different widths.
AT_SETUP([AUTORECODE group vs. strings])
AT_DATA([ar-strings.sps],
  [data list notable list /a (a12) b (a6).
begin data.
one    nine
two    ten
three  eleven 
four   nought
end data.

autorecode a b into x y 
	/group.

list.
])

AT_CHECK([pspp -O format=csv ar-strings.sps], [0],
[dnl
Table: Data List
a,b,x,y
one         ,nine  ,5.00,3.00
two         ,ten   ,8.00,6.00
three       ,eleven,7.00,1.00
four        ,nought,2.00,4.00
])

AT_CLEANUP



AT_SETUP([AUTORECODE /blank])

AT_DATA([auto-blank.sps],  [dnl
data list notable list /x (a8) y * z (a16).
begin data.
one   2  fred
two   4  ""
""    4  fred
""    2  charliebrown
three 2  charliebrown
end data.

autorecode variables x y z into a b c  /blank=missing.

list a b c y.
])

AT_CHECK([pspp -O format=csv auto-blank.sps], [0], [dnl
Table: Data List
a,b,c,y
1.00,1.00,2.00,2.00
3.00,2.00,.  ,4.00
.  ,2.00,2.00,4.00
.  ,1.00,1.00,2.00
2.00,1.00,1.00,2.00
])

AT_CLEANUP

dnl AUTORECODE had a use-after-free error when TEMPORARY was in use.
dnl Bug #32757.
AT_SETUP([AUTORECODE with TEMPORARY])
AT_DATA([autorecode.sps],
  [data list /X 1-5(a) Y 7.
begin data.
lasdj 1
asdfk 0
asdfj 2
asdfj 1
asdfk 2
asdfj 9
lajks 9
asdfk 0
asdfk 1
end data.

temporary.
select if y > 1.
autorecode x y into A B/descend.
list.
])
AT_CHECK([pspp -O format=csv autorecode.sps], [0],
  [Table: Reading 1 record from INLINE.
Variable,Record,Columns,Format
X,1,1-  5,A5
Y,1,7-  7,F1.0

Table: Data List
X,Y,A,B
lasdj,1,.  ,.  @&t@
asdfk,0,2.00,.  @&t@
asdfj,2,3.00,2.00
asdfj,1,3.00,.  @&t@
asdfk,2,2.00,2.00
asdfj,9,3.00,1.00
lajks,9,1.00,1.00
asdfk,0,2.00,.  @&t@
asdfk,1,2.00,.  @&t@
])
AT_CLEANUP