Diff for "FAQ/missing" - CBU statistics Wiki
location: Diff for "FAQ/missing"
Differences between revisions 3 and 4
Revision 3 as of 2007-06-19 10:25:22
Size: 965
Editor: PeterWatson
Comment:
Revision 4 as of 2007-06-19 10:26:18
Size: 963
Editor: PeterWatson
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:

 
== How do I handle missing data in SPSS? ==
== How do I handle missing data in SPSS? == 

== How do I handle missing data in SPSS? ==

Here are two macros for replacing missing values in SPSS. Suppose we have 50 variables labelled in consecutive columns aq1 to aq50. The below macro will identify only complete cases.

compute ind=1.
exe.

define !inmiss ( !pos !tokens(1)
                          / !pos !tokens(1)) .
!do !i=!1 !to !2.
if missing(!concat(aq,!i)) ind=ind*0.
!doend.
!enddefine.

!inmiss 1 50.
exe.
USE ALL.
COMPUTE filter_$=(ind=1).
VARIABLE LABEL filter_$ 'ind=1 (FILTER)'.
VALUE LABELS filter_$  0 'Selected' 1 'Not Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE .

The below macro will replace the missing values with the variable mean

define !inmiss ( !pos !tokens(1)
                          / !pos !tokens(1)) .
!do !i=!1 !to !2.
rmv /!concat(aq,!i,a)=smean(!concat(aq,!i)).
compute !concat(aq,!i,a) = rnd(aq,!1,a).
!doend.
!enddefine.

!inmiss 1 50.
exe.

None: FAQ/missing (last edited 2021-09-02 09:18:20 by PeterWatson)