7.2.3 Imputing scores: SPSS syntax

 
get file="indexandmeans.sav". 
* Assume we have subgroup means in the relevant variables as above egs. 
* Assume missing scores are coded -999, which is not an SPSS 'missing value'. 
recode all (missing,sysmis=-999). 
missing values all (-777). 
* Use the following macros to speed up imputation commands :. 
* Macro 1 : for title only unit. 
define imput1 (var=!tokens(1) ). 
do if (!var=-999). 
if (!concat('o1',!var) gt -100) !var=!concat('o1',!var). 
if (!concat('o2',!var) gt -100) !var=!concat('o2',!var). 
if (!concat('o3',!var) gt -100) !var=!concat('o3',!var). 
end if. 
!enddefine. 
* this macro prioritises the scores of o3, then o2, then ol etc. 
* STILL NEED TO ADD TITLE ONLY SCORE. 
* with the appropriate substitutions, that can be original, then title, 
* then minor group, then submj, then major gp averages. 
* Macro 2 : title-by-status unit :. 
define imput2 (var=!tokens(1) ). 
do if (!var=-999). 
if (!concat('o1',!var) gt -100) !var=!concat('o1',!var). 
if (!concat('o2',!var) gt -100) !var=!concat('o2',!var). 
if (!concat('o1s',!var) gt -100) !var=!concat('o1s',!var). 
if (!concat('o3',!var) gt -100) !var=!concat('o3',!var). 
if (!concat('o2s',!var) gt -100) !var=!concat('o2s',!var). 
if (!concat('o4',!var) gt -100) !var=!concat('o4',!var). 
if (!concat('o3s',!var) gt -100) !var=!concat('o3s',!var). 
end if. 
!enddefine. 

* Check the data before starting :. 
missing values htd1cs 
  zhtd1 wtd1cs zwtd1 hsd1cs zhsd1 wsd1cs zwsd1 o1htm o1zhtm o1wtm o1zwtm o2htm o2zhtm 
  o2wtm o2zwtm o3htm o3zhtm o3wtm o3zwtm o1hsm o1zhsm o1wsm o1zwsm o2hsm o2zhsm 
  o2wsm o2zwsm o3hsm o3zhsm o3wsm o3zwsm o4hsm o4zhsm o4wsm o4zwsm o1shsm o1szhsm 
  o1swsm o1szwsm o2shsm o2szhsm o2swsm o2szwsm o3shsm o3szhsm o3swsm o3szwsm (-999). 
descriptives var=htd1cs zhtd1 wtd1cs zwtd1 hsd1cs zhsd1 wsd1cs zwsd1 o1htm o1zhtm 
  o1wtm o1zwtm o2htm o2zhtm o2wtm o2zwtm o3htm o3zhtm o3wtm o3zwtm o1hsm o1zhsm 
  o1wsm o1zwsm o2hsm o2zhsm o2wsm o2zwsm o3hsm o3zhsm o3wsm o3zwsm o4hsm o4zhsm 
  o4wsm o4zwsm o1shsm o1szhsm o1swsm o1szwsm o2shsm o2szhsm o2swsm o2szwsm o3shsm 
  o3szhsm o3swsm o3szwsm . 
missing values htd1cs zhtd1 wtd1cs zwtd1 hsd1cs zhsd1 
  wsd1cs zwsd1 o1htm o1zhtm o1wtm o1zwtm o2htm o2zhtm o2wtm o2zwtm o3htm o3zhtm 
  o3wtm o3zwtm o1hsm o1zhsm o1wsm o1zwsm o2hsm o2zhsm o2wsm o2zwsm o3hsm o3zhsm 
  o3wsm o3zwsm o4hsm o4zhsm o4wsm o4zwsm o1shsm o1szhsm o1swsm o1szwsm o2shsm o2szhsm 
  o2swsm o2szwsm o3shsm o3szhsm o3swsm o3szwsm (-777). 
* Title only units :. 
imput1 var=htm. 
imput1 var=zhtm. 
imput1 var=wtm. 
imput1 var=zwtm. 
* Title by status units :. 
imput2 var=hsm. 
imput2 var=zhsm. 
imput2 var=wsm. 
imput2 var=zwsm. 


Return to Imputed scores


Last modified 14 February 2002
This document is maintained by Paul Lambert (paul.lambert@stirling.ac.uk)