818bf5f51d278dcba760dacb388c31f35efd5226
[pspp] / tests / language / dictionary / modify-variables.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl 
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.
8 dnl 
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.
13 dnl 
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/>.
16 dnl
17 AT_BANNER([MODIFY VARS])
18
19 AT_SETUP([MODIFY VARS /REORDER])
20 AT_KEYWORDS([REORDER])
21 AT_DATA([modify-variables.sps], [dnl
22 DATA LIST LIST /a b c x y z (F2.0).
23 BEGIN DATA.
24 1 2 3 4 5 6
25 END DATA.
26
27 MODIFY VARS /REORDER (z y x).
28 DISPLAY INDEX.
29 MODIFY VARS /REORDER (c b a).
30 DISPLAY INDEX.
31
32 MODIFY VARS /REORDER BACKWARD (z y x).
33 DISPLAY INDEX.
34 MODIFY VARS /REORDER BACKWARD (c b a).
35 DISPLAY INDEX.
36
37 MODIFY VARS /REORDER BACKWARD ALPHA (ALL).
38 DISPLAY INDEX.
39 MODIFY VARS /REORDER ALPHA (ALL).
40 DISPLAY INDEX.
41 ])
42 AT_CHECK([pspp -O format=csv modify-variables.sps], [0], [dnl
43 Table: Reading free-form data from INLINE.
44 Variable,Format
45 a,F2.0
46 b,F2.0
47 c,F2.0
48 x,F2.0
49 y,F2.0
50 z,F2.0
51
52 Table: Variables
53 Name,Position
54 z,1
55 y,2
56 x,3
57 a,4
58 b,5
59 c,6
60
61 Table: Variables
62 Name,Position
63 c,1
64 b,2
65 a,3
66 z,4
67 y,5
68 x,6
69
70 Table: Variables
71 Name,Position
72 x,1
73 y,2
74 z,3
75 c,4
76 b,5
77 a,6
78
79 Table: Variables
80 Name,Position
81 a,1
82 b,2
83 c,3
84 x,4
85 y,5
86 z,6
87
88 Table: Variables
89 Name,Position
90 z,1
91 y,2
92 x,3
93 c,4
94 b,5
95 a,6
96
97 Table: Variables
98 Name,Position
99 a,1
100 b,2
101 c,3
102 x,4
103 y,5
104 z,6
105 ])
106 AT_CLEANUP
107
108 AT_SETUP([MODIFY VARS /RENAME])
109 AT_KEYWORDS([RENAME])
110 AT_DATA([modify-variables.sps], [dnl
111 DATA LIST LIST /a b c x y z (F2.0).
112 BEGIN DATA.
113 1 2 3 4 5 6
114 END DATA.
115
116 MODIFY VARS /RENAME (a b c = one two three).
117 DISPLAY INDEX.
118 MODIFY VARS /RENAME (one two three = a b c).
119 DISPLAY INDEX.
120 MODIFY VARS /RENAME (a = a).
121 DISPLAY INDEX.
122 MODIFY VARS /RENAME (a b c = b c a).
123 DISPLAY INDEX.
124 ])
125 AT_CHECK([pspp -O format=csv modify-variables.sps], [0], [dnl
126 Table: Reading free-form data from INLINE.
127 Variable,Format
128 a,F2.0
129 b,F2.0
130 c,F2.0
131 x,F2.0
132 y,F2.0
133 z,F2.0
134
135 Table: Variables
136 Name,Position
137 one,1
138 two,2
139 three,3
140 x,4
141 y,5
142 z,6
143
144 Table: Variables
145 Name,Position
146 a,1
147 b,2
148 c,3
149 x,4
150 y,5
151 z,6
152
153 Table: Variables
154 Name,Position
155 a,1
156 b,2
157 c,3
158 x,4
159 y,5
160 z,6
161
162 Table: Variables
163 Name,Position
164 b,1
165 c,2
166 a,3
167 x,4
168 y,5
169 z,6
170 ])
171 AT_CLEANUP
172
173 AT_SETUP([MODIFY VARS /DROP and /KEEP])
174 AT_KEYWORDS([DROP KEEP])
175 AT_DATA([modify-variables.sps], [dnl
176 DATA LIST LIST /a b c x y z (F2.0).
177 BEGIN DATA.
178 1 2 3 4 5 6
179 END DATA.
180
181 MODIFY VARS /DROP a.
182 DISPLAY INDEX.
183 MODIFY VARS /KEEP ALL.
184 DISPLAY INDEX.
185 MODIFY VARS /KEEP c TO y.
186 DISPLAY INDEX.
187 MODIFY VARS /DROP x.
188 DISPLAY INDEX.
189 MODIFY VARS /KEEP y.
190 DISPLAY INDEX.
191 MODIFY VARS /DROP y.
192 DISPLAY INDEX.
193 ])
194 AT_CHECK([pspp -O format=csv modify-variables.sps], [1], [dnl
195 Table: Reading free-form data from INLINE.
196 Variable,Format
197 a,F2.0
198 b,F2.0
199 c,F2.0
200 x,F2.0
201 y,F2.0
202 z,F2.0
203
204 Table: Variables
205 Name,Position
206 b,1
207 c,2
208 x,3
209 y,4
210 z,5
211
212 Table: Variables
213 Name,Position
214 b,1
215 c,2
216 x,3
217 y,4
218 z,5
219
220 Table: Variables
221 Name,Position
222 c,1
223 x,2
224 y,3
225
226 Table: Variables
227 Name,Position
228 c,1
229 y,2
230
231 Table: Variables
232 Name,Position
233 y,1
234
235 modify-variables.sps:16: error: MODIFY VARS: MODIFY VARS may not be used to delete all variables from the active dataset dictionary.  Use NEW FILE instead.
236
237 modify-variables.sps:17: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
238 ])
239 AT_CLEANUP