I want to generate a binary variable name “eldest” as follows:
if a person is the most aged person in a household, then eldest =1,
if a person is NOT the most aged person in a household, then eldest =0
The command I used is as follows:
gen eldest=0
bysort hhid: replace eldest=1 if max(age)
by its says "Invalid syntax"
What is the problem?
What is the correct way to do it?
Thank You
0 Response to max and if together
Post a Comment