I am trying to generate a variable for the age of the oldest male in the household.
So, I am using the variables from the household roster in the NIDS dataset.
I have identified variables such as a household residence or living in the household, gender (male) and year of birth (age).
I want to generate or create a variable for the age oldest male in the household.
Then, I want to place him (male) side by side with the female that is receiving benefit within the same household.
Please see what I have done in my dofile;
******** generating age of the oldest male ********// generating male age
*1* living in the residence according to household roster
codebook r_pres
numlabel, add
tab r_pres
gen hhres=.
replace hhres=1 if r_pres==1
*replace hhres=0 if r_pres==2
*drop if r_pres==3
* // Just rename
*ren r_pres hhres
*2* year of birth to generate age in the household roster
codebook r_dob_y
tab r_dob_y
drop if r_dob_y==9999
ren r_dob_y ageh
gen yr=2017
gen agehh=yr-ageh
tab agehh
*3* gender / sex in the household roster
br r_gen
*ren r_gen // male = 1, female = 2 //
gen sexM=.
replace sexM=1 if r_gen==1
replace sexM=0 if r_gen==2
tab sexM
*4* females receiving the benefit
OAPr
*/ age of the oldest male living in the household (AOmhh) ********//
egen AOmhh= max(agehh) if sexM==1 & hhres==1, by (pid)
Please, how do I generate a variable age of the oldest male in the household?
Thanks in anticipation for your help.
Related Posts with Generate a new variable
Exact test statistic comapring avg. marignal effects after logit?Dear all, can anyone point me towards a place to look for the exact statistic for the comparison of…
Compare restricted and full model that are pooled and p-weightedDear All! The issue I want to solve is: I have two data points in time, whereas in 8% not the same …
Normalizing VariablesHi - I am working with Panel data comprising 820 companies across 19 years. My data includes financi…
predictDear colleagues, what is the difference between predict,structural and predict command in stata afte…
asdoc on stata for logit regressionWhen I write logit X Y asdoc logit, or I get the word print out version of the coefficients table.…
Subscribe to:
Post Comments (Atom)
0 Response to Generate a new variable
Post a Comment