DEFINE Center ( IDVar !CharEnd ('/') /Vars !CharEnd ('/') /DVars !CMDEnd). /* -------------------------------------------------------------- */ /* --- MACRO to compute deviation-scores of variables 1..p --- */ /* -------------------------------------------------------------- */ /* To use this macro the list of variables (next VARS) must be */ /* specified together with names of the new variables (next */ /* /DVARS) which will contain the deviation scores (centered */ /* variabels with mean=0). */ /* The variables specified next /DVARS will be added to the */ /* current working file. The deviation scores will be computed */ /* with listwise deletion of missing cases and may thus differ */ /* from one list of variables to another. */ /* If the variables next /DVARS exist already, the macro will */ /* overwrite their current content. */ /* Example: */ /* You want to compute the deviation scores of the variables x1, */ /* x2, x25, x49 into the new variables dx1, dx2, dx25, dx49. If */ /* there is no variable containing an identification number for */ /* each case it must be computed before calling the macro (as */ /* we assume in this example). */ /* */ /* COMPUTE LfdNr = $CASENUM. */ /* */ /* The respective macro-procedure CENTER is called by: */ /* */ /* Center IDVar = LfdNr */ /* /Vars = x1,x2,x25,x49 */ /* /DVARS = dx1,dx2,dx25,dx49. */ do repeat #var=!DVARS. + compute #var=0. end repeat. sort cases by !IDVar. save outfile='C:\WINDOWS\TEMP\origtemp.tmp' /drop !DVARS. matrix. get rawdat /File = * /variables = !IDVar !vars /missing=omit. compute idvek = rawdat(:,1). save idvek /outfile = 'C:\WINDOWS\TEMP\idvek.tmp' /variables = !IDVar. compute datmat = rawdat(:,2:ncol(rawdat)). save datmat /outfile = 'C:\WINDOWS\TEMP\datmat.tmp' /variables = !vars. end matrix. matrix. get X /file = 'C:\WINDOWS\TEMP\datmat.tmp' /variables = !vars /missing = omit. compute D = X-(Make(NRow(X),1,1)*(CSum(X)/NRow(X))). print NRow(X) /title"N (cases):" /FORMAT = "F10.0". print NCol(X) /title"P (variables):" /FORMAT = "F10.0". * print D * /title"deviation scores:" * /FORMAT = "F10.0". save D /outfile=* /variables=!DVARS. END MATRIX. match files /file=* /file='C:\WINDOWS\TEMP\idvek.tmp'. execute. match files /file='C:\WINDOWS\TEMP\origtemp.tmp' /file=* /by !IDVar. execute. erase file='C:\WINDOWS\TEMP\idvek.tmp'. erase file='C:\WINDOWS\TEMP\datmat.tmp'. erase file='C:\WINDOWS\TEMP\origtemp.tmp'. !EndDefine. /* --------------------------------------------------------- */. /* The macro is called by: */. /* */. /* Center IDVar = variable containing casenumbers */. /* /VARS = variables */. /* /DVARS = new variables. */. /* --------------------------------------------------------- */.