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
Random match between two large surveys with weightsI have two different large-ish surveys of the US adult population. The two in principle are measurin…
Converting DMS coordinates to decimal in StataHi! Can someone please tell me if it's possible to convert DMS coordinates to decimal in Stata? I am…
.dta files do not open from project managerDear all, I cannot open .dta files by double-clicking on them in the project manager window. To be …
Two ID variables for each rowHey all, In advance would like to say sorry for experienced users for asking this (just cannot find …
stcox: Continuous Time Varying CovariatesWhen evaluating the effect of a continuous covariate that changes from one wave to the next, (in thi…
Subscribe to:
Post Comments (Atom)
0 Response to max and if together
Post a Comment