Implement missing values for long string variables.
[pspp] / tests / command / weight.sh
1 #!/bin/sh
2
3 # This program tests the WEIGHT 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
24 cleanup()
25 {
26      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
27         echo "NOT cleaning $TEMPDIR"
28         return ; 
29      fi
30      cd /
31      rm -rf $TEMPDIR
32 }
33
34
35 fail()
36 {
37     echo $activity
38     echo FAILED
39     cleanup;
40     exit 1;
41 }
42
43
44 no_result()
45 {
46     echo $activity
47     echo NO RESULT;
48     cleanup;
49     exit 2;
50 }
51
52 pass()
53 {
54     cleanup;
55     exit 0;
56 }
57
58 mkdir -p $TEMPDIR
59
60 cd $TEMPDIR
61
62 activity="create program"
63 cat > $TESTFILE << EOF
64 SET FORMAT F8.3.
65 data list file='$top_srcdir/tests/weighting.data'/AVAR 1-5 BVAR 6-10.
66 weight by BVAR.
67
68 descriptives AVAR /statistics all /format serial.
69 frequencies AVAR /statistics all /format condense.
70
71 EOF
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74
75 activity="run program"
76 $SUPERVISOR $PSPP --testing-mode $TESTFILE
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79 activity="compare results"
80 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
81 diff  -b $TEMPDIR/pspp.list - <<EOF
82 1.1 DATA LIST.  Reading 1 record from "$top_srcdir/tests/weighting.data".
83 +--------+------+-------+------+
84 |Variable|Record|Columns|Format|
85 #========#======#=======#======#
86 |AVAR    |     1|  1-  5|F5.0  |
87 |BVAR    |     1|  6- 10|F5.0  |
88 +--------+------+-------+------+
89 2.1 DESCRIPTIVES.  Valid cases = 730; cases with missing value(s) = 0.
90 +--------#-------+---------+------+--------+-------+--------+--------+--------+--------+--------+------+-------+-------+--------+
91 |Variable#Valid N|Missing N| Mean |S E Mean|Std Dev|Variance|Kurtosis|S E Kurt|Skewness|S E Skew| Range|Minimum|Maximum|   Sum  |
92 #========#=======#=========#======#========#=======#========#========#========#========#========#======#=======#=======#========#
93 |AVAR    #    730|        0|31.515|    .405| 10.937| 119.608|   2.411|    .181|   1.345|    .090|76.000| 18.000| 94.000|23006.00|
94 +--------#-------+---------+------+--------+-------+--------+--------+--------+--------+--------+------+-------+-------+--------+
95 3.1 FREQUENCIES.  AVAR
96 +--------+--------+---+---+
97 |        |        |   |Cum|
98 |  Value |  Freq  |Pct|Pct|
99 #========#========#===#===#
100 |      18|       1|.13|.13|
101 |      19|       7|.95|1.0|
102 |      20|      26|3.5|4.6|
103 |      21|      76|10.|15.|
104 |      22|      57|7.8|22.|
105 |      23|      58|7.9|30.|
106 |      24|      38|5.2|36.|
107 |      25|      38|5.2|41.|
108 |      26|      30|4.1|45.|
109 |      27|      21|2.8|48.|
110 |      28|      23|3.1|51.|
111 |      29|      24|3.2|54.|
112 |      30|      23|3.1|57.|
113 |      31|      14|1.9|59.|
114 |      32|      21|2.8|62.|
115 |      33|      21|2.8|65.|
116 |      34|      14|1.9|67.|
117 |      35|      14|1.9|69.|
118 |      36|      17|2.3|71.|
119 |      37|      11|1.5|73.|
120 |      38|      16|2.1|75.|
121 |      39|      14|1.9|77.|
122 |      40|      15|2.0|79.|
123 |      41|      14|1.9|81.|
124 |      42|      14|1.9|83.|
125 |      43|       8|1.0|84.|
126 |      44|      15|2.0|86.|
127 |      45|      10|1.3|87.|
128 |      46|      12|1.6|89.|
129 |      47|      13|1.7|91.|
130 |      48|      13|1.7|92.|
131 |      49|       5|.68|93.|
132 |      50|       5|.68|94.|
133 |      51|       3|.41|94.|
134 |      52|       7|.95|95.|
135 |      53|       6|.82|96.|
136 |      54|       2|.27|96.|
137 |      55|       2|.27|96.|
138 |      56|       2|.27|97.|
139 |      57|       3|.41|97.|
140 |      58|       1|.13|97.|
141 |      59|       3|.41|98.|
142 |      61|       1|.13|98.|
143 |      62|       3|.41|98.|
144 |      63|       1|.13|98.|
145 |      64|       1|.13|99.|
146 |      65|       2|.27|99.|
147 |      70|       1|.13|99.|
148 |      78|       1|.13|99.|
149 |      79|       1|.13|99.|
150 |      80|       1|.13|99.|
151 |      94|       1|.13|100|
152 +--------+--------+---+---+
153 +-----------------------+--------+
154 |N           Valid      |     730|
155 |            Missing    |       0|
156 |Mean                   |  31.515|
157 |S.E. Mean              |    .405|
158 |Mode                   |  21.000|
159 |Std Dev                |  10.937|
160 |Variance               | 119.608|
161 |Kurtosis               |   2.411|
162 |S.E. Kurt              |    .181|
163 |Skewness               |   1.345|
164 |S.E. Skew              |    .090|
165 |Range                  |  76.000|
166 |Minimum                |  18.000|
167 |Maximum                |  94.000|
168 |Sum                    |23006.00|
169 |Percentiles 50 (Median)|      29|
170 +-----------------------+--------+
171 EOF
172 if [ $? -ne 0 ] ; then fail ; fi
173
174
175 pass;