Hello STATA Experts: I am trying to create a new variable based on the existence of certain conditions in two existing variables (see code below). It appears to be dropping most of the cases for "Fathers". Not sure what is wrong here. Also, how is this treating missing variables?
Any help would be appreciated. Pat
generate parentfigure=.
replace parentfigure=0 if X1HPAR1==2 | X1HPAR2==2
replace parentfigure=1 if X1HPAR1==1
label define parentfigurelab 0 "Father" 1 "Mother"
label values parentfigure parentfigurelab
label variable parentfigure "Parent Figure"
Related Posts with Generating a New Variable based on Conditional IF Statements
Using CD directories in local myfilesHi, Is it possible to put the CD directory on local myfiles? My command is local myfiles: dir "C:…
Relative coefficientsDear All, Can someone help me to understand how to obtain coefficients relative to the absolute val…
How to Sum or add Across Column with if commandHello Fellow Statalist, I have a dataset that contains the following vatiables: Date, CIF, FOB, Cou…
Why Stata omits or does not omit treat-variable when using weights with difference-in-difference with fixed effects.Hi, I hope there is some simple reason for this, but I just could not wrap my head around this. Per…
Linear predictionsHi everyone! I have a linear relationship between the variables y and x, and I am plotting the line…
Subscribe to:
Post Comments (Atom)
0 Response to Generating a New Variable based on Conditional IF Statements
Post a Comment