Dear all
Sorry for reposting this. I sent that out a week ago but did not get an answer. It may not have been distributed completely; I only got one 'out of office' answer. Here my problem again: I select six cases upon a certain criteria out of a larger data set. Sometimes these six cases have only missing valus. I save the selected cases and subsequently use an ADD FILES command. When all six files are empty, the resulting file is empty as well. I then use a VARSTOCASES command. That should give me the value 0.00 in a variable named 'trans' for all nine cases (INDEX = Index1(9). I then do an AGGREGATE command do calculate the mean and the standard deviation of 'trans'. If all six cases selected in the first step had only missing values, I should get a mean = 0.00 and a standard deviation of 0.00. However, when I repeatedly do that as part of a larger routine, I sometimes get an absurdly high value for one of the values in 'trans'. This happens not all the time; neither the occurrence is regularly, nor comes the wrong mean always as the same value. Typically, the wrong value appears one to two times when I repeat the procedure 10 times. Below is a code that reproduces the error (at least on my computer) and prints the calculated means. It runs 10 times through the ADD FILES, VARSTOCASES, and AGGREGATE commands. 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 The Syntax 1. creates six empty files 2. add them (resulting in an empty file) 3. restructures the empty file (VARSTOCASES) 4. aggregates the restructured file 5. writes the aggregated values into a syntax file 6. prints the values 7. erases the created syntax files (from step 5) Is that a SPSS bug? Can somebody reproduce that? 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 Data. 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. * Make mean. ************. 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. Exec. * Print the created means (should all be '.0000'). ***************************************************. Title "Results:". 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. Exec. !DOEND. !ENDDEFINE. !DoPrint. Echo " ". * 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] |
Free forum by Nabble | Edit this page |