< LT Is less than > GT Is greater than <> NE Is not to <= LE Is less than or equal to >= GE Is greater than or equal to & AND Both relational operators must be true | OR Either relational operator can be true. (The is typed by pressing “|” the shift key + the backslash key) ~ NOT Reverses the result of a relational operator (i.e. ~= for not equal”; ~> for not greater than.” “is “is Showing you how these operators work, will be easiest with examples where we create dummy variables: To create the new variable we could use the following syntax, which creates that “male,” variable and leaves all of its observation with blank responses: compute male = $SYSMIS. EXECUTE. Next, we could change the value of based on the value of the original variable “male” “gender,” where 1= male; 2=female. To make a dummy variable, we could use this syntax: “male” If (gender=1) male = 1. If (gender=2) male = 0. EXECUTE. Notice, because the original value of is coded to missing data ($SYSMIS), it is not “male” necessary to transfer over any information about missing data from the gender variable. If data are missing for the gender variable, will still $SYSMIS. “male” In a second example, let us assume that we are creating a dummy variable to identify respondents who are CHRISTIAN (coded 1=yes; 0=no), based on a responses listed in the variable RELIGTRAD (which codes respondents: 1=non-religious, 2=Protestant, 3=Buddhist, 4=Catholic… 98= Don’t know, 99= Didn’t respond). We might use this syntax: Most basic: compute CHRISTIAN = 0. if (RELIGTRAD =1) CHRISTIAN = 1. if (RELIGTRAD =4) CHRISTIAN = 1. if (RELIGTRAD =$SYSMIS) CHRISTIAN = $SYSMIS. if RELIGTRAD >=98) CHRISTIAN = $SYSMIS. EXECUTE.
< LT Is less than > GT Is greater than <> NE Is not to <= LE Is less than or equal to >= GE Is greater than or equal to & AND Both relational operators must be true | OR Either relational operator can be true. (The “|” is typed by pressing the shift key + the backslash key) ~ NOT Reverses the result of a relational operator (i.e. ~= for “is not equal”; ~> for “is not greater than.” Showing you how these operators work, will be easiest with examples where we create dummy variables: To create the new variable “male,” we could use the following syntax, which creates that variable and leaves all of its observation with blank responses: compute male = $SYSMIS. EXECUTE. Next, we could change the value of “male” based on the value of the original variable “gender,” where 1= male; 2=female. To make a dummy “male” variable, we could use this syntax: If (gender=1) male = 1. If (gender=2) male = 0. EXECUTE. Notice, because the original value of “male” is coded to missing data ($SYSMIS), it is not necessary to transfer over any information about missing data from the gender variable. If data are missing for the gender variable, “male” will still $SYSMIS. In a second example, let us assume that we are creating a dummy variable to identify respondents who are CHRISTIAN (coded 1=yes; 0=no), based on a responses listed in the variable RELIGTRAD (which codes respondents: 1=non-religious, 2=Protestant, 3=Buddhist, 4=Catholic… 98= Don’t know, 99= Didn’t respond). We might use this syntax: Most basic: compute CHRISTIAN = 0. if (RELIGTRAD =1) CHRISTIAN = 1. if (RELIGTRAD =4) CHRISTIAN = 1. if (RELIGTRAD =$SYSMIS) CHRISTIAN = $SYSMIS. if RELIGTRAD >=98) CHRISTIAN = $SYSMIS. EXECUTE.