QUESTION 3 - ANSWER

How would you create a new variable that is equal to 1 if the respondent is a women and equal to 0 if the respondent is a man (use the gender variable to identify the gender of the respondents)?

To construct the new variable you need to use both the generate and replace commands. To create the new variable you type:

gen newvar2 = 0
replace newvar2 = 1 if gender == 2

The first command creates a new variable called newvar2, each observation in the data set has a value of 0 for this new variable. The second step recodes the newvar2 values from 0 to the value 1 if the gender variable is equal to 2.

Does this seem right? Did you type this instead?:

replace newvar2 = 1 if gender == Female

Continue on with Module 3 for an explanation of the above syntax.

Back to Questions