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
Predictors of improvement over timeDear statalist members, I would like to model predictors of improvement in a binary variable over t…
25th UK Stata Conference (London): First Announcement and Call for Presentations25th UK Stata Conference (London): First Announcement and Call for Presentations Dates: Thursday 5 …
Merge not matching for one year for a specific variable unrelated to the mergeI am looking at data on recycling and compost rates and have merged this data with recycling and was…
Aggregating individual-level data to studysite-level dataDear all, I am still very new to Stata and would need your help with the following: I am currently …
paired data problemI have data for the lipid profile before treatment, 4 weeks, 12 weeks after treatment. Paired data …
Subscribe to:
Post Comments (Atom)
0 Response to max and if together
Post a Comment