6446c3448779c764682516268689067672614d1a
[pspp-builds.git] / tests / command / weight.sh
1 #!/bin/sh
2
3 # This program tests the WEIGHT command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 here=`pwd`;
8
9 # ensure that top_srcdir is absolute
10 cd $top_srcdir; top_srcdir=`pwd`
11
12 export STAT_CONFIG_PATH=$top_srcdir/config
13
14
15 cleanup()
16 {
17      rm -rf $TEMPDIR
18 }
19
20
21 fail()
22 {
23     echo $activity
24     echo FAILED
25     cleanup;
26     exit 1;
27 }
28
29
30 no_result()
31 {
32     echo $activity
33     echo NO RESULT;
34     cleanup;
35     exit 2;
36 }
37
38 pass()
39 {
40     cleanup;
41     exit 0;
42 }
43
44 mkdir -p $TEMPDIR
45
46 cd $TEMPDIR
47
48 activity="create program"
49 cat > $TEMPDIR/weight.stat <<EOF
50 data list file='$here/weighting.data'/AVAR 1-5 BVAR 6-10.
51 weight by BVAR.
52
53 descriptives AVAR /statistics all /format serial.
54 frequencies AVAR /statistics all /format condensed.
55
56 EOF
57 if [ $? -ne 0 ] ; then no_result ; fi
58
59
60 activity="run program"
61 $here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/weight.stat
62 if [ $? -ne 0 ] ; then no_result ; fi
63
64
65 activity="compare results"
66 diff -B -b $TEMPDIR/pspp.list - <<EOF
67 1.1 DATA LIST.  Reading 1 record from file "/tmp/pspp/tests/weighting.data".
68 +--------+------+-------+------+
69 |Variable|Record|Columns|Format|
70 #========#======#=======#======#
71 |AVAR    |     1|  1-  5|F5.0  |
72 |BVAR    |     1|  6- 10|F5.0  |
73 +--------+------+-------+------+
74
75 2.1(1) DESCRIPTIVES.  Valid cases = 730; cases with missing value(s) = 0.
76 +--------#-------+---------+------+--------+-------+--------+--------+--------+
77 |Variable#Valid N|Missing N| Mean |S E Mean|Std Dev|Variance|Kurtosis|S E Kurt|
78 #========#=======#=========#======#========#=======#========#========#========#
79 |AVAR    #    730|        0|31.515|    .405| 10.937| 119.608|2548.162|    .181|
80 +--------#-------+---------+------+--------+-------+--------+--------+--------+
81
82 2.1(2) DESCRIPTIVES.  Valid cases = 730; cases with missing value(s) = 0.
83 +--------#--------+--------+------+-------+-------+---------+
84 |Variable#Skewness|S E Skew| Range|Minimum|Maximum|   Sum   |
85 #========#========#========#======#=======#=======#=========#
86 |AVAR    #   1.345|    .090|76.000| 18.000| 94.000|23006.000|
87 +--------#--------+--------+------+-------+-------+---------+
88
89 3.1 FREQUENCIES.  AVAR: 
90 +--------+--------+---+---+
91 |        |        |   |Cum|
92 |  Value |  Freq  |Pct|Pct|
93 #========#========#===#===#
94 |      18|       1|  0|  0|
95 |      19|       7|  1|  1|
96 |      20|      26|  4|  5|
97 |      21|      76| 10| 15|
98 |      22|      57|  8| 23|
99 |      23|      58|  8| 31|
100 |      24|      38|  5| 36|
101 |      25|      38|  5| 41|
102 |      26|      30|  4| 45|
103 |      27|      21|  3| 48|
104 |      28|      23|  3| 51|
105 |      29|      24|  3| 55|
106 |      30|      23|  3| 58|
107 |      31|      14|  2| 60|
108 |      32|      21|  3| 63|
109 |      33|      21|  3| 65|
110 |      34|      14|  2| 67|
111 |      35|      14|  2| 69|
112 |      36|      17|  2| 72|
113 |      37|      11|  2| 73|
114 |      38|      16|  2| 75|
115 |      39|      14|  2| 77|
116 |      40|      15|  2| 79|
117 |      41|      14|  2| 81|
118 |      42|      14|  2| 83|
119 |      43|       8|  1| 84|
120 |      44|      15|  2| 86|
121 |      45|      10|  1| 88|
122 |      46|      12|  2| 89|
123 |      47|      13|  2| 91|
124 |      48|      13|  2| 93|
125 |      49|       5|  1| 94|
126 |      50|       5|  1| 94|
127 |      51|       3|  0| 95|
128 |      52|       7|  1| 96|
129 |      53|       6|  1| 96|
130 |      54|       2|  0| 97|
131 |      55|       2|  0| 97|
132 |      56|       2|  0| 97|
133 |      57|       3|  0| 98|
134 |      58|       1|  0| 98|
135 |      59|       3|  0| 98|
136 |      61|       1|  0| 98|
137 |      62|       3|  0| 99|
138 |      63|       1|  0| 99|
139 |      64|       1|  0| 99|
140 |      65|       2|  0| 99|
141 |      70|       1|  0| 99|
142 |      78|       1|  0|100|
143 |      79|       1|  0|100|
144 |      80|       1|  0|100|
145 |      94|       1|  0|100|
146 +--------+--------+---+---+
147
148 Mean         31.515
149 S.E. Mean      .405
150 Median            .
151 Mode         21.000
152 Std Dev      10.937
153 Variance    119.608
154 Kurtosis      2.411
155 S.E. Kurt      .181
156 Skewness      1.345
157 S.E. Skew      .090
158 Range        76.000
159 Minimum      18.000
160 Maximum      94.000
161 Sum       23006.000
162
163 EOF
164 if [ $? -ne 0 ] ; then fail ; fi
165
166
167 pass;