== 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. }}}