*** This file is copied from Brendan Halpin's website, ** http://www.ul.ie/sociology/brendan.halpin.html . ** It can be run as an include file to define the macro ffactor. * Jul 27 1998 16:00:26 * Macros for Loglinear Analysis course, August 1998. * 1: zFACTOR: creates a vector of dummy (indicator) variables from * a single categorical variable. * Example: "factor job jb 4" creates jb1 jb2 jb3 and jb 4, with * values of zero and one depending on the value of job, a 4-value * categorical variable. *-----------------------------------------------------------------. define factor (!pos !tok(1) /!pos !tok(1) /!pos !tok(1)). * fac-var, new vector, number of values. * Jul 15 1998 14:15:13 Creates a vector-suitable set of dummy variables from a categorical variable. Errors will be generated if the categorical value has non-missing values outside the range 1 -- arg-3. Existing variables with the same names will be overwritten. * Create/initialise-to-zero the dummy vector. !DO !i = 1 !TO !3 compute !concat(!2,!i)=0. !DOEND vector dumm = !concat(!2,1) to !concat(!2,!3) . if not missing(!1) dumm(!1)=1. !enddefine. ***************************************************.