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([cat pspp.csv | sed '/^Table/d
83 s/^\([[a-z0-9]]*\),.*,\([[^,]]*\)$/\1: \2/'], [0], [dnl
93 date1: 9999998; 9999984; 3
94 num1: 9999998; 9999984; 3
108 date1: 13342665600; 12495427200
109 num1: 13342665600; 12495427200
111 date1: 13342665600; 12495427200; 12570336000
112 num1: 13342665600; 12495427200; 12570336000
126 num1: LOWEST THRU 2; 3
128 num1: LOWEST THRU 2; 3
130 num1: 1 THRU HIGHEST; -1
132 num1: 1 THRU HIGHEST; -1
134 str1: """abc ""; ""def """
135 str2: """abc""; ""def"""
136 longstr: """abc ""; ""def """
146 AT_SETUP([MISSING VALUES invalid cases])
147 AT_DATA([missing-values.sps], [dnl
148 DATA LIST NOTABLE/str1 1-5 (A) str2 6-8 (A) date1 9-19 (DATE) num1 20-25
152 MISSING VALUES str1 str2 longstr ('abcde').
154 * Long string missing value longer than 8 bytes.
155 MISSING VALUES longstr ('abcdefghijk').
158 MISSING VALUES str1 ('a' THRU 'z').
160 * Mixing string and numeric variables.
161 MISSING VALUES str1 num1 ('123').
164 MISSING VALUES num1 (1, 2, 3, 4).
165 MISSING VALUES num1 (1 THRU 2, 3 THRU 4).
166 MISSING VALUES num1 (1, 2 THRU 3, 4).
167 MISSING VALUES str1 ('abc', 'def', 'ghi', 'jkl').
170 MISSING VALUES num1 (2 THRU 1).
172 AT_CHECK([pspp -O format=csv missing-values.sps], [1], [dnl
173 missing-values.sps:5: error: MISSING VALUES: Missing values provided are too long to assign to variable of width 3.
175 missing-values.sps:8: error: MISSING VALUES: Truncating missing value to maximum acceptable length (8 bytes).
177 missing-values.sps:11.26-11.29: error: MISSING VALUES: Syntax error at `THRU': expecting string.
179 missing-values.sps:11: error: MISSING VALUES: THRU is not a variable name.
181 missing-values.sps:14: error: MISSING VALUES: Cannot mix numeric variables (e.g. num1) and string variables (e.g. str1) within a single list.
183 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.
185 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.
187 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.
189 missing-values.sps:20: error: MISSING VALUES: Too many string missing values. At most three individual values are allowed.
191 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.