QUESTION 6 - ANSWER

How would you create a new variable called "head" that is equal to 1 if the individual is the resident head, and equal to 0 if the individual is not?

Answer: The first step to creating the new variable head is to find a variable in the data set that will tell us who is and is not a resident head. To accomplish this, use the command lookfor to see which variables and/or variable labels contain the key text "resident head".

lookfor resident head

The above command displays three variables, mcode, rel_head, and resident. Using the SALDRU survey, we determine which of these variables is the appropriate measure. It becomes clear after viewing the survey (page 4, under "Codes for Question 3") that rel_head is the correct variable. From the SALDRU survey we see that a resident head is given a value of 1, thus when the variable rel_head is equal to 1, that individual is a resident head.

With this knowledge, we are able to create the new variable.

generate head = 0
replace head = 1 if rel_head == 1

The first command above creates a new variable called head that is equal to zero for every observation in the data. The second command line replaces the existing value of the variable head if the original variable rel_head is equal to 1, thus creating the desired variable.

Back to Questions