SPSS bug?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

SPSS bug?

la volta statistics
Dear all

I discovered a strange behaviour of SPSS 14.
When I repeatedly add empty files using the ADD FILES command and
subsequently do a VARSTOCASES command to display the number of cases in the
a made variable named 'trans' and do then an aggregation to get the mean and
the standard deviation from the variable 'trans' the most of the time I get
zero. This is correct. However, if I do that repeatedly in a macro from time
to time the mean is not zero but absurdly high such as 2.9E+184 and the
standard deviation becomes INV.

Below is a code that creates the error (at least on my computer) and prints
the calculated means.
The result is for example:
mean = .0000
mean = 9.7E+288
mean = .0000
mean = .0000
mean = .0000
mean = .0000
mean = .0000
mean = .0000
mean = 2.9E+184
mean = .0000

Note: neither the occurrence is regularly, nor comes the wrong mean always
as the same value.

Is that a SPSS bug?

Christian

* BEGIN OF SYNTAX.

* Syntax to reproduce the wrong mean.
*************************************.
NEW FILE.
DATASET CLOSE all.

DATA LIST FREE /qrel Q1a Q2a Q3a Q4a Q5a Q6a Q7a Q8a Q9a
                   imp_1 imp_2 imp_3 imp_4 imp_5 imp_6 imp_7 imp_8 imp_9
               Caegory Questions.
begin data.
end data.

* Make 6 empty data files .
**************************.
DEFINE !DoTbl   ().
!LET !nby = 6.
!DO !cnt=1 !TO !nby.
!LET !Path = !QUOTE(!CONCAT('c:\Temp\tmp_',!cnt,'.sav') ).
Save Outfile = !Path.
!DOEND.
!ENDDEFINE.

!DoTbl.

* Caluclate mean from the number of cases.
******************************************.
DEFINE !DoData   ().

!LET !nby = 10.
!DO !cnt=1 !TO !nby.

!LET !Path1 = !QUOTE(!CONCAT('c:\Temp\tmp_1.sav') ).
!LET !Path2 = !QUOTE(!CONCAT('c:\Temp\tmp_2.sav') ).
!LET !Path3 = !QUOTE(!CONCAT('c:\Temp\tmp_3.sav') ).
!LET !Path4 = !QUOTE(!CONCAT('c:\Temp\tmp_4.sav') ).
!LET !Path5 = !QUOTE(!CONCAT('c:\Temp\tmp_5.sav') ).
!LET !Path6 = !QUOTE(!CONCAT('c:\Temp\tmp_6.sav') ).

New File.
DATASET CLOSE ALL.

Get FILE = !Path1.

ADD FILES /FILE=*
 /FILE = !Path2
 /FILE = !Path3
 /FILE = !Path4
 /FILE = !Path5
 /FILE = !Path6.
Exec.

OMS /DESTINATION VIEWER=NO .
VARSTOCASES
 /MAKE trans FROM Q1a to Q9a
 /INDEX = Index1(9)
 /NULL = DROP
 /DROP = QREL  imp_1 to imp_9 Caegory Questions
 /COUNT = Counter .
Exec.
OMSEND.

Compute dummy = 1.
DATASET DECLARE Agg.
AGGREGATE
  /OUTFILE ='Agg'
  /BREAK   = dummy
  /Self_mean = MEAN(trans)
  /Self_sd = SD(trans).
Exec.
DATASET ACTIVE agg.
FORMAT Self_Mean (F8.4).
FORMAT Self_SD   (F8.4).

!LET !PathA = !QUOTE(!CONCAT('c:\Temp\myMean_',!cnt,'.sps') ).
!LET !PathB = !QUOTE(!CONCAT('c:\Temp\myMean_',!cnt,'.sps') ).

!LET !myMean = !QUOTE(!CONCAT("DEFINE !Tb_Mean",!cnt,"()") ).
!LET !mySD = !QUOTE(!CONCAT("DEFINE !Tb_Std",!cnt,"()") ).

WRITE OUTFILE !PathA/!myMean/Self_Mean/"!ENDDEFINE."/"Exec.".
WRITE OUTFILE !PathA/!mySD/Self_SD/"!ENDDEFINE."/"Exec.".
EXEC.

!DOEND.

!ENDDEFINE.
!DoData.
!DoData.
Exec.

* Print the created means (should all be '.0000').
***************************************************.
DEFINE !DoPrint   ().

!LET !nby = 10.
!DO !cnt=1 !TO !nby.
!LET !PathA = !QUOTE(!CONCAT('c:\Temp\myMean_',!cnt,'.sps') ).
INSERT  FILE = !PathA.

!LET !Print = !CONCAT('mean = ','!Tb_mean',!cnt).

TITLE !Print.

!DOEND.
!ENDDEFINE.
!DoPrint.

* Clean up.
**********.

DEFINE !DoClean   ().

!LET !nby = 10.
!DO !cnt=1 !TO !nby.
!LET !PathA = !QUOTE(!CONCAT('c:\Temp\myMean_',!cnt,'.sps') ).

ERASE FILE = !PathA.
!DOEND.

!LET !nby2 = 6.
!DO !cnt2=1 !TO !nby2.
!LET !Path = !QUOTE(!CONCAT('c:\Temp\tmp_',!cnt2,'.sav') ).
ERASE FILE= !Path.
!DOEND.
!ENDDEFINE.
!DoClean   .
EXEC.


* END OF SYNTAX.

*******************************
la volta statistics
Christian Schmidhauser, Dr.phil.II
Weinbergstrasse 108
Ch-8006 Zürich
Tel: +41 (043) 233 98 01
Fax: +41 (043) 233 98 02
mailto:[hidden email]