Hi everyone, Masters Economics student here, struggling with using Stata. Probably a very simple question to those that are competent in using Stata, but it's got me confused.
I have a dataset (British Household Panel Survey), with an independent variable "qmastat", which is an individual's self-reported marital status. The variable is numeric and the measurements are nominal. The values are as follows:
- 9 = missing/wild
- 8 = inapplicable
- 2 = refused
- 1 = not answered
0 = child under 16
1 = married
2 = living as couple
3 = widowed
4 = divorced
5 = separated
6 = never married
7 = civil partnership
8 = dissolved civil partnership
I am trying to create a new dummy variable called "married", which should take on the value of 1 if married (qmastat = 1), 0 if not married (qmastat = 2, 3, 4, 5, 6, 7 or 8), and . if missing (qmastat < 0).
I know that if I were to create a simpler dummy variable (such as gender), I would use the commands: generate female = 1 if qsex == 2 ; replace female = 0 if qsex == 1; replace female = . if qsex < 0.
Please could someone offer some advice with regards to how I would create a dummy variable for married? I'm guessing it would be something along the lines of generate married = 1 if qmastat = 1; replace married = 0 if qmastat > 1 ?
Also, if i were, for example, to want to create a similar variable for married or living as a couple (qmastat = 1 or 2), how would I go about programming that?
Many thanks in advanced.
Will
I have a dataset (British Household Panel Survey), with an independent variable "qmastat", which is an individual's self-reported marital status. The variable is numeric and the measurements are nominal. The values are as follows:
- 9 = missing/wild
- 8 = inapplicable
- 2 = refused
- 1 = not answered
0 = child under 16
1 = married
2 = living as couple
3 = widowed
4 = divorced
5 = separated
6 = never married
7 = civil partnership
8 = dissolved civil partnership
I am trying to create a new dummy variable called "married", which should take on the value of 1 if married (qmastat = 1), 0 if not married (qmastat = 2, 3, 4, 5, 6, 7 or 8), and . if missing (qmastat < 0).
I know that if I were to create a simpler dummy variable (such as gender), I would use the commands: generate female = 1 if qsex == 2 ; replace female = 0 if qsex == 1; replace female = . if qsex < 0.
Please could someone offer some advice with regards to how I would create a dummy variable for married? I'm guessing it would be something along the lines of generate married = 1 if qmastat = 1; replace married = 0 if qmastat > 1 ?
Also, if i were, for example, to want to create a similar variable for married or living as a couple (qmastat = 1 or 2), how would I go about programming that?
Many thanks in advanced.
Will
Comment