I have three variables gender sector and wf. Gender and sector are categorical variables, where gender takes values between male and female & sector takes a value between rural and urban. wf is a binary variable which takes the value 1 if the individual is in the workforce and zero otherwise. I want to create four new variables rural_male_wf, rural_female_wf, urban_male_wf and urban_female_wf that take value from variable wf if an individual is from the rural sector and male and so on. Can someone please help me regarding the same?
clear
input str5(sector gender) float(wf rural_male_wf rural_female_wf urban_male_wf urban_female_wf)
"rural" "male" 0 0 . . .
"rural" "femal" 1 . 1 . .
"urban" "male" 1 . . 1 .
"rural" "male" 1 1 . . .
"urban" "femal" 0 . . . 0
"urban" "femal" 0 . . . 0
"rural" "femal" 1 . 1 . .
"rural" "male" 0 0 . . .
"urban" "femal" 1 . . . 1
"urban" "male" 0 . . 0 .
"urban" "male" 1 . . 1 .
"rural" "femal" 0 . 0 . .
"rural" "male" 1 1 . . .
"urban" "male" 0 . . 0 .
end
Related Posts with Create new variables using two categorical variables
Predictions using gologit2 - issues applying coeffcients to validation datasetI'm new to Stata, so apologies in advance if this is a basic question. I am having some issues apply…
Generate an initiale value for each five year interval in unbalanced panel dataHi dear Statalister, I have an unbalanced panel data and i want to generate a new variable. This var…
Merging multiple Spss data sets into STATAHi, I'm trying to merge a few UNICEF MICS survey data files together which are on Spss onto stata, f…
Forcing my Event Study through R2000 in loopsHey Everyone, I'm currently trying to run a regression/prediction of some abnormal returns. All goo…
Specification of funnel plot with -funnelcompar-Hi Statalisters I want to assess county differences in medication rates in Norway to detect outlier…
Subscribe to:
Post Comments (Atom)
0 Response to Create new variables using two categorical variables
Post a Comment