View Full Version : SPSS syntax for missing data
psychologygirl
06-29-2008, 01:30 PM
If I wanted to substitute the means for missing data for questionnaires I am using, but only if participants completed no less than 70% of the items, what would the syntax be. Any help would be most welcome! Thanks!
publichealthresearcher
08-30-2008, 03:10 PM
Same here! I am struggling to find out. Let you know if it was sorted out.
Hmmm. Something like that?
* QUESTION: How to replace missing values of scale1 TO scale17 by the mean
* value but only when number of missing is less than 75% of scales.
* ANSWER posted to SPSSX-L on 2001/5/15 by rlevesque@videotron.ca.
* Define dummy data file for illustration purposes.
NEW file.
INPUT PROGRAM.
SET SEED=7654321.
VECTOR scale(17F8.3).
LOOP id=1 TO 50.
LEAVE id.
LOOP #id=1 TO 17.
* about 25% of scales will be missing.
IF (UNIFORM(1)<.75) scale(#id)=TRUNC(UNIFORM(5)+.5).
END LOOP.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
EXECUTE.
* Start the job.
COMPUTE dummy=1.
AGGREGATE OUTFILE='c:\temp\mydata.sav'
/BREAK=dummy
/mscale1 to mscale17=mean(scale1 to scale17).
MATCH FILES FILE=* /TABLE='c:\temp\mydata.sav' /by dummy.
DO IF (NMISS(scale1 to scale17) < 17*.25).
+ DO REPEAT orig = scale1 to scale17 /copy=mscale1 to mscale17.
+ if (missing (orig)) orig=copy.
+ END REPEAT.
END IF.
EXECUTE.
> Free Syntax files (http://pages.infinit.net/rlevesqu/SampleSyntax.htm) (a lots!)
Powered by vBulletin™ Version 4.1.3 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.