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
Question about Goodness of fit resultHi, I am running a SEM model on Stata. I've 5 IVs, 1 mediator, and DV. with the sample size of 400. …
Problem with graph combineHello, I am trying to combine some graphs. I generate the graphs and save them into a folder. When I…
VISUA Dialog programming GUII have seen the presentation on the below link, they have used a VISUA GUI for creating Stata Dialog…
Converting string to date/time variables fails somehowHello Statalist community, I am struggeling with converting a string containing date and time inform…
Problem with importing excel on new MacBookHi, I recently started working on a new MacBook from my old MacBook (i.e. I transferred all files, …
Subscribe to:
Post Comments (Atom)
0 Response to Generate a new variable
Post a Comment