I'm new to Stata but familiar with stat programs I thought this would be easy. I'm trying to create a new variable (G02) which takes on the value of another variable (Obs) if a third variable's condition (Gap) is met. I tried to do this when the third variable was a string variable and got an error: type mismatch so I changed the third variable so that all were numeric and I still get an error - invalid syntax.
generate G02 = Obs if Gap=2
invalid syntax
r(198);
I did it again with generate G02 = . and then replacing G02 using the same if statement and got the same invalid syntax issue.
I need to break down Gap into a bunch of new variables depending on the value of Gap. Why can't I make this work? Thanks for you help.
generate G02 = Obs if Gap=2
invalid syntax
r(198);
I did it again with generate G02 = . and then replacing G02 using the same if statement and got the same invalid syntax issue.
I need to break down Gap into a bunch of new variables depending on the value of Gap. Why can't I make this work? Thanks for you help.
Comment