Hi,
I need to generate a variable which is combination of two variables. In our survey the question " Do you want more children?" has been asked from women and saved in the data set based on the pregnancy at the moment. So we ended up with the same question asked from women (Non-preganant and pregnant) in two variables. I need to combine these two variables in one variable regardless of variable of pregnancy. I wanted to use the function -cond()- that Nick Cox thought me here once, but I can't get the appropriate variable.
I know I can generate the new variable using gen and replace commands, but I wanted to learn to use -cond()- function in the future.
I appreciate your inputs.
I need to generate a variable which is combination of two variables. In our survey the question " Do you want more children?" has been asked from women and saved in the data set based on the pregnancy at the moment. So we ended up with the same question asked from women (Non-preganant and pregnant) in two variables. I need to combine these two variables in one variable regardless of variable of pregnancy. I wanted to use the function -cond()- that Nick Cox thought me here once, but I can't get the appropriate variable.
I know I can generate the new variable using gen and replace commands, but I wanted to learn to use -cond()- function in the future.
I appreciate your inputs.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long(pregnant more_children more_children_pregnant) 0 1 . 0 1 . 1 . 1 0 3 . 0 2 . 0 1 . 0 1 . -88 1 . 0 1 . 0 1 . 0 2 . 0 2 . 0 1 . 0 -88 . 1 . 1 0 1 . 0 1 . 0 1 . 0 1 . 0 1 . 0 1 . 0 3 . 0 2 . 0 1 . 0 1 . 0 1 . 0 -88 . 0 1 . 0 1 . 0 2 . 0 2 . 0 3 . 0 1 . 0 1 . 0 1 . 0 1 . 0 1 . 0 2 . 0 -88 . 0 3 . 0 1 . 0 1 . 1 . 1 0 2 . 0 2 . 0 -88 . 0 1 . 0 1 . 1 . -88 0 1 . 0 -88 . 0 1 . 0 1 . 0 1 . 0 -88 . 0 -88 . 0 -88 . 0 1 . 0 1 . 0 1 . -88 2 . 1 . 1 0 1 . 0 2 . 1 . -88 0 2 . 0 2 . 0 -88 . 0 1 . 0 1 . 0 2 . 0 2 . 0 -88 . 1 . -88 0 1 . 0 3 . 0 1 . 0 1 . 0 1 . 0 1 . 0 1 . 0 1 . 1 . 1 0 1 . 0 1 . 0 1 . 0 1 . 0 2 . 0 1 . 0 1 . 1 . 1 0 1 . 0 1 . 0 -88 . 0 2 . 0 1 . 0 1 . 0 1 . 1 . 2 0 1 . end label values pregnant yesno label def yesno -88 "-88", modify label def yesno 0 "no", modify label def yesno 1 "yes", modify label values more_children morechildrenlist label values more_children_pregnant morechildrenlist label def morechildrenlist -88 "-88", modify label def morechildrenlist 1 "have_child", modify label def morechildrenlist 2 "no_children", modify label def morechildrenlist 3 "infertile", modify
Comment