Hello stata users
Im trying to generate dummies for birth order in children within households. I want to generate three dummies: first_born middle_child and last_child. Im trying to run the following code but can´t seem to use the min or max functions as conditionals for stata:
sort idhousehold age
bysort idhousehold : gen first_born = 1 if age==max(age) & if relation==3
bysort idhousehold : gen middle_child = 1 if age>max(age) & age<max(age) & if relation==3
bysort idhousehold : gen last_child = 1 if age==min(age) & if relation==3
The conditional relation==3 means that this will be only generated for the ones that are identified as child inside the household.
Thanks in advance!
Alfonso
Im trying to generate dummies for birth order in children within households. I want to generate three dummies: first_born middle_child and last_child. Im trying to run the following code but can´t seem to use the min or max functions as conditionals for stata:
sort idhousehold age
bysort idhousehold : gen first_born = 1 if age==max(age) & if relation==3
bysort idhousehold : gen middle_child = 1 if age>max(age) & age<max(age) & if relation==3
bysort idhousehold : gen last_child = 1 if age==min(age) & if relation==3
The conditional relation==3 means that this will be only generated for the ones that are identified as child inside the household.
Thanks in advance!
Alfonso
Comment