3ca027191983fe4cf2edc3289e4621a0d96e58b7
[pspp] / tests / command / examine.sh
1 #!/bin/sh
2
3 # This program tests  the EXAMINE command.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23 cleanup()
24 {
25      cd /
26      rm -rf $TEMPDIR
27 }
28
29
30 fail()
31 {
32     echo $activity
33     echo FAILED
34     cleanup;
35     exit 1;
36 }
37
38
39 no_result()
40 {
41     echo $activity
42     echo NO RESULT;
43     cleanup;
44     exit 2;
45 }
46
47 pass()
48 {
49     cleanup;
50     exit 0;
51 }
52
53 mkdir -p $TEMPDIR
54
55 cd $TEMPDIR
56
57 activity="create program"
58 cat > $TESTFILE <<EOF
59 DATA LIST LIST /QUALITY * W * BRAND * .
60 BEGIN DATA
61 3  1  1
62 2  2  1
63 1  2  1
64 1  1  1
65 4  1  1
66 4  1  1
67 5  1  2
68 2  1  2
69 4  4  2
70 2  1  2
71 3  1  2
72 7  1  3
73 4  2  3
74 5  3  3
75 3  1  3
76 6  1  3
77 END DATA
78
79 WEIGHT BY w.
80
81 VARIABLE LABELS brand   'Manufacturer'.
82 VARIABLE LABELS quality 'Breaking Strain'.
83
84 VALUE LABELS /brand 1 'Aspeger' 2 'Bloggs' 3 'Charlies'.
85
86 LIST /FORMAT=NUMBERED.
87
88 EXAMINE
89         quality BY brand
90         /STATISTICS descriptives extreme(3)
91         .
92 EOF
93 if [ $? -ne 0 ] ; then no_result ; fi
94
95
96 activity="run program"
97 $SUPERVISOR $PSPP -o raw-ascii $TESTFILE
98 if [ $? -ne 0 ] ; then no_result ; fi
99
100 # NOTE:  In the following data: Only the extreme values have been checked
101 # The descriptives have been blindly pasted.
102 activity="compare results"
103 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
104 diff -b  $TEMPDIR/pspp.list - << EOF
105 1.1 DATA LIST.  Reading free-form data from INLINE.
106 +--------+------+
107 |Variable|Format|
108 #========#======#
109 |QUALITY |F8.0  |
110 |W       |F8.0  |
111 |BRAND   |F8.0  |
112 +--------+------+
113 Case#  QUALITY        W    BRAND
114 ----- -------- -------- --------
115     1     3.00     1.00     1.00
116     2     2.00     2.00     1.00
117     3     1.00     2.00     1.00
118     4     1.00     1.00     1.00
119     5     4.00     1.00     1.00
120     6     4.00     1.00     1.00
121     7     5.00     1.00     2.00
122     8     2.00     1.00     2.00
123     9     4.00     4.00     2.00
124    10     2.00     1.00     2.00
125    11     3.00     1.00     2.00
126    12     7.00     1.00     3.00
127    13     4.00     2.00     3.00
128    14     5.00     3.00     3.00
129    15     3.00     1.00     3.00
130    16     6.00     1.00     3.00
131 2.1 EXAMINE.  Case Processing Summary
132 #===============#===============================#
133 #               #             Cases             #
134 #               #----------+---------+----------#
135 #               #   Valid  | Missing |   Total  #
136 #               #--+-------+-+-------+--+-------#
137 #               # N|Percent|N|Percent| N|Percent#
138 #===============#==#=======#=#=======#==#=======#
139 #Breaking Strain#24|   100%|0|     0%|24|   100%#
140 #===============#==#=======#=#=======#==#=======#
141 2.2 EXAMINE.  Extreme Values
142 #=========================#===========#=====#
143 #                         #Case Number|Value#
144 #=========================#===========#=====#
145 #Breaking Strain Highest 1#         12| 7.00#
146 #                        2#         16| 6.00#
147 #                        3#         14| 5.00#
148 #               ----------#-----------+-----#
149 #                 Lowest 1#          4| 1.00#
150 #                        2#          3| 1.00#
151 #                        3#          3| 1.00#
152 #=========================#===========#=====#
153 2.3 EXAMINE.  Descriptives
154 #============================================================#=========#==========#
155 #                                                            #Statistic|Std. Error#
156 #============================================================#=========#==========#
157 #Breaking Strain Mean                                        #   3.54  |   .324   #
158 #                95% Confidence Interval for Mean Lower Bound#  3.562  |          #
159 #                                                 Upper Bound#  3.521  |          #
160 #                5% Trimmed Mean                             #   3.50  |          #
161 #                Median                                      #   4.00  |          #
162 #                Variance                                    #  2.520  |          #
163 #                Std. Deviation                              #  1.587  |          #
164 #                Minimum                                     #  1.000  |          #
165 #                Maximum                                     #  7.000  |          #
166 #                Range                                       #  6.000  |          #
167 #                Interquartile Range                         #   2.75  |          #
168 #                Skewness                                    #   .059  |   .472   #
169 #                Kurtosis                                    #  -.358  |   .918   #
170 #============================================================#=========#==========#
171 2.4 EXAMINE.  Case Processing Summary
172 #============================#=============================#
173 #                            #            Cases            #
174 #                            #---------+---------+---------#
175 #                            #  Valid  | Missing |  Total  #
176 #                            #-+-------+-+-------+-+-------#
177 #                Manufacturer#N|Percent|N|Percent|N|Percent#
178 #============================#=#=======#=#=======#=#=======#
179 #Breaking Strain Aspeger     #8|   100%|0|     0%|8|   100%#
180 #                Bloggs      #8|   100%|0|     0%|8|   100%#
181 #                Charlies    #8|   100%|0|     0%|8|   100%#
182 #============================#=#=======#=#=======#=#=======#
183 2.5 EXAMINE.  Extreme Values
184 #======================================#===========#=====#
185 #                Manufacturer          #Case Number|Value#
186 #======================================#===========#=====#
187 #Breaking Strain Aspeger      Highest 1#          6| 4.00#
188 #                                     2#          5| 4.00#
189 #                                     3#          1| 3.00#
190 #                            ----------#-----------+-----#
191 #                              Lowest 1#          4| 1.00#
192 #                                     2#          3| 1.00#
193 #                                     3#          3| 1.00#
194 #               -----------------------#-----------+-----#
195 #                Bloggs       Highest 1#          7| 5.00#
196 #                                     2#          9| 4.00#
197 #                                     3#          9| 4.00#
198 #                            ----------#-----------+-----#
199 #                              Lowest 1#         10| 2.00#
200 #                                     2#          8| 2.00#
201 #                                     3#         11| 3.00#
202 #               -----------------------#-----------+-----#
203 #                Charlies     Highest 1#         12| 7.00#
204 #                                     2#         16| 6.00#
205 #                                     3#         14| 5.00#
206 #                            ----------#-----------+-----#
207 #                              Lowest 1#         15| 3.00#
208 #                                     2#         13| 4.00#
209 #                                     3#         13| 4.00#
210 #======================================#===========#=====#
211 2.6 EXAMINE.  Descriptives
212 #=========================================================================#=========#==========#
213 #                Manufacturer                                            #Statistic|Std. Error#
214 #=========================================================================#=========#==========#
215 #Breaking Strain Aspeger      Mean                                        #   2.25  |   .453   #
216 #                             95% Confidence Interval for Mean Lower Bound#  2.279  |          #
217 #                                                              Upper Bound#  2.221  |          #
218 #                             5% Trimmed Mean                             #   2.22  |          #
219 #                             Median                                      #   2.00  |          #
220 #                             Variance                                    #  1.643  |          #
221 #                             Std. Deviation                              #  1.282  |          #
222 #                             Minimum                                     #  1.000  |          #
223 #                             Maximum                                     #  4.000  |          #
224 #                             Range                                       #  3.000  |          #
225 #                             Interquartile Range                         #   2.75  |          #
226 #                             Skewness                                    #   .475  |   .752   #
227 #                             Kurtosis                                    #  -1.546 |   1.481  #
228 #               ----------------------------------------------------------#---------+----------#
229 #                Bloggs       Mean                                        #   3.50  |   .378   #
230 #                             95% Confidence Interval for Mean Lower Bound#  3.525  |          #
231 #                                                              Upper Bound#  3.475  |          #
232 #                             5% Trimmed Mean                             #   3.50  |          #
233 #                             Median                                      #   4.00  |          #
234 #                             Variance                                    #  1.143  |          #
235 #                             Std. Deviation                              #  1.069  |          #
236 #                             Minimum                                     #  2.000  |          #
237 #                             Maximum                                     #  5.000  |          #
238 #                             Range                                       #  3.000  |          #
239 #                             Interquartile Range                         #   1.75  |          #
240 #                             Skewness                                    #  -.468  |   .752   #
241 #                             Kurtosis                                    #  -.831  |   1.481  #
242 #               ----------------------------------------------------------#---------+----------#
243 #                Charlies     Mean                                        #   4.88  |   .441   #
244 #                             95% Confidence Interval for Mean Lower Bound#  4.904  |          #
245 #                                                              Upper Bound#  4.846  |          #
246 #                             5% Trimmed Mean                             #   4.86  |          #
247 #                             Median                                      #   5.00  |          #
248 #                             Variance                                    #  1.554  |          #
249 #                             Std. Deviation                              #  1.246  |          #
250 #                             Minimum                                     #  3.000  |          #
251 #                             Maximum                                     #  7.000  |          #
252 #                             Range                                       #  4.000  |          #
253 #                             Interquartile Range                         #   1.75  |          #
254 #                             Skewness                                    #   .304  |   .752   #
255 #                             Kurtosis                                    #   .146  |   1.481  #
256 #=========================================================================#=========#==========#
257 EOF
258 if [ $? -ne 0 ] ; then fail ; fi
259
260 pass