Is there a reason why there are two different commands to generate a new variable?
Is there a simple way to remember when to use gen and when to use egen?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
They both create a new variable, but work with different sets of functions. You will typically use
genwhen you have simple transformations of other variables in your dataset likeIn my workflow,
egenusually appears when I need functions that work across all observations, like inor more complex instructions
to calculate the maximum for each observation between
oldvar1andoldvar2. I don’t think there is a clear logic for separating the two commands.