Hi all
First, let me say I am a 4th-year psychology student doing her Honours thesis, I am NOT a statistician so my knowledge of Stata is probably very basic compared to most users here! I need to create a new variable as follows:
existing var 1 - children under 5? yes/no where yes = 1, no = 2
existing var 2 - children under 16? yes/no where yes = 1, no = 2
new var - children between 5 and 16 years
I am looking at both gen and egen functions but I can't see a way to tell Stata that I want the new variable to include those who responded No/2 to existing var 1 and those who responded Yes/1 to existing var 2.
Can anyone help me out? I'm using Stata/MP 17.0
thank you!
Mel
Related Posts with Help to generate a new variable using 2 existing variables
First occurrenceHi all, I have a dataset with the launch_date (data_lancio) for each molecule, which is repeated ov…
Conditional code blockDoes Stata have a way to do conditional code blocks, i.e. Code: if condition { do this do this do …
Using "if" and "and" commands while generating variablesI have a numeric variable, say x. A lot of values are 0. The rest are all positive. I want to create…
use loop (e.g., foreach) across two vars to derive a third var (30 iterations)Hello All, I have 30 pairs of variables from which I need to derive 30 new variables. I'd like to u…
PlottingThere are two groups- X and Y. X has n1 observtion, Y has n2 observation. Each observation of X and …
Subscribe to:
Post Comments (Atom)
0 Response to Help to generate a new variable using 2 existing variables
Post a Comment