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
Related Posts with max and if together
How to interpret interactions in negative binomial regressionDear Statalist users, I am currently working on a study on how to increase complementor participatio…
Append one variable after another in the same datasetHello, This is part of my dataset. What I want to do is to append contri_dia2 contri_dia3 contri_d…
what to do about missing gender and ethnicity data?Hi all, I am working on a demographic analysis on who is applying for jobs and who is selected, and…
non linear estimation with hundreds of variablesDear all, I am trying to run a non linear estimation of beta in the following specification: yi = ln…
one test subject, several answers - how to recode?Hi, my friend has a (string) variabel of which the test subjects could answer from one to several we…
Subscribe to:
Post Comments (Atom)
0 Response to max and if together
Post a Comment