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([MISSING VALUES])
19 AT_SETUP([MISSING VALUES valid cases])
20 AT_DATA([missing-values.sps], [dnl
21 DATA LIST NOTABLE/str1 1-5 (A) str2 6-8 (A) date1 9-19 (DATE) num1 20-25
24 * Numeric missing values.
25 MISSING VALUES date1 num1 (1).
26 DISPLAY DICTIONARY date1 num1.
27 MISSING VALUES date1 num1 (1, 2).
28 DISPLAY DICTIONARY date1 num1.
29 MISSING VALUES date1 num1 (1, 2, 3).
30 DISPLAY DICTIONARY date1 num1.
31 MISSING VALUES date1 num1 (9999998, 9999984, 3).
32 DISPLAY DICTIONARY date1 num1.
34 * Numeric missing values using the first variable's format.
35 MISSING VALUES num1 date1 ('1').
36 DISPLAY DICTIONARY date1 num1.
37 MISSING VALUES num1 date1 ('1', '2').
38 DISPLAY DICTIONARY date1 num1.
39 MISSING VALUES num1 date1 ('1', '2', '3').
40 DISPLAY DICTIONARY date1 num1.
41 MISSING VALUES date1 num1 ('06-AUG-05').
42 DISPLAY DICTIONARY date1 num1.
43 MISSING VALUES date1 num1 ('06-AUG-05', '01-OCT-78').
44 DISPLAY DICTIONARY date1 num1.
45 MISSING VALUES date1 num1 ('06-AUG-05', '01-OCT-78', '14-FEB-81').
46 DISPLAY DICTIONARY date1 num1.
48 * Ranges of numeric missing values.
49 MISSING VALUES num1 (1 THRU 2).
50 DISPLAY DICTIONARY num1.
51 MISSING VALUES num1 (LO THRU 2).
52 DISPLAY DICTIONARY num1.
53 MISSING VALUES num1 (LOWEST THRU 2).
54 DISPLAY DICTIONARY num1.
55 MISSING VALUES num1 (1 THRU HI).
56 DISPLAY DICTIONARY num1.
57 MISSING VALUES num1 (1 THRU HIGHEST).
58 DISPLAY DICTIONARY num1.
60 * A range of numeric missing values, plus an individual value.
61 MISSING VALUES num1 (1 THRU 2, 3).
62 DISPLAY DICTIONARY num1.
63 MISSING VALUES num1 (LO THRU 2, 3).
64 DISPLAY DICTIONARY num1.
65 MISSING VALUES num1 (LOWEST THRU 2, 3).
66 DISPLAY DICTIONARY num1.
67 MISSING VALUES num1 (1 THRU HI, -1).
68 DISPLAY DICTIONARY num1.
69 MISSING VALUES num1 (1 THRU HIGHEST, -1).
70 DISPLAY DICTIONARY num1.
72 * String missing values.
73 MISSING VALUES str1 str2 longstr ('abc ','def').
74 DISPLAY DICTIONARY str1 str2 longstr.
76 * May mix variable types when clearing missing values.
77 MISSING VALUES ALL ().
80 AT_CHECK([pspp -o pspp.csv missing-values.sps])
81 AT_CHECK([sed -n '/^$/p; /^@<:@^"@:>@*"@<:@^"@:>@*$/N; s/^\(@<:@a-z0-9@:>@*\),".*Missing Values: \(.*\)",@<:@0-9@:>@*$/\1: \2/p; s/^\(@<:@a-z0-9@:>@*\),Format: @<:@A-Z0-9.@:>@*,@<:@0-9@:>@*$/\1: none/p' pspp.csv
92 date1: 9999998; 9999984; 3
93 num1: 9999998; 9999984; 3
107 date1: 13342665600; 12495427200
108 num1: 13342665600; 12495427200
110 date1: 13342665600; 12495427200; 12570336000
111 num1: 13342665600; 12495427200; 12570336000
125 num1: LOWEST THRU 2; 3
127 num1: LOWEST THRU 2; 3
129 num1: 1 THRU HIGHEST; -1
131 num1: 1 THRU HIGHEST; -1
133 str1: ""abc ""; ""def ""
134 str2: ""abc""; ""def""
135 longstr: ""abc ""; ""def ""
145 AT_SETUP([MISSING VALUES invalid cases])
146 AT_DATA([missing-values.sps], [dnl
147 DATA LIST NOTABLE/str1 1-5 (A) str2 6-8 (A) date1 9-19 (DATE) num1 20-25
151 MISSING VALUES str1 str2 longstr ('abcde').
153 * Long string missing value longer than 8 bytes.
154 MISSING VALUES longstr ('abcdefghijk').
157 MISSING VALUES str1 ('a' THRU 'z').
159 * Mixing string and numeric variables.
160 MISSING VALUES str1 num1 ('123').
163 MISSING VALUES num1 (1, 2, 3, 4).
164 MISSING VALUES num1 (1 THRU 2, 3 THRU 4).
165 MISSING VALUES num1 (1, 2 THRU 3, 4).
166 MISSING VALUES str1 ('abc', 'def', 'ghi', 'jkl').
169 MISSING VALUES num1 (2 THRU 1).
171 AT_CHECK([pspp -O format=csv missing-values.sps], [1], [dnl
172 missing-values.sps:5: error: MISSING VALUES: Missing values provided are too long to assign to variable of width 3.
174 missing-values.sps:8: error: MISSING VALUES: Truncating missing value to maximum acceptable length (8 bytes).
176 missing-values.sps:11.26-11.29: error: MISSING VALUES: Syntax error at `THRU': expecting string.
178 missing-values.sps:11: error: MISSING VALUES: THRU is not a variable name.
180 missing-values.sps:14: error: MISSING VALUES: Cannot mix numeric variables (e.g. num1) and string variables (e.g. str1) within a single list.
182 missing-values.sps:17: error: MISSING VALUES: Too many numeric missing values. At most three individual values or one value and one range are allowed.
184 missing-values.sps:18: error: MISSING VALUES: Too many numeric missing values. At most three individual values or one value and one range are allowed.
186 missing-values.sps:19: error: MISSING VALUES: Too many numeric missing values. At most three individual values or one value and one range are allowed.
188 missing-values.sps:20: error: MISSING VALUES: Too many string missing values. At most three individual values are allowed.
190 missing-values.sps:23: warning: MISSING VALUES: The high end of the range (1) is below the low end (2). The range will be treated as if reversed.