Hi,
I am using individual-level dataset across 4 years to try and calculate the mobility out of low wage between 2020 and 2017. I created these dummy variables (delta2020 and delta2017) expressing 1 if low wage and 0 if not.
However, I need to subtract delta2020 with delta2017 for the same individual (Person_Ref1).
How can I create a variable like diff below?
input Person_Ref1Person_Ref2 delta2020 delta2017 diff
"1000501" "2017" . 1 .
"1000501" "2018" . . .
"1000501" "2019" . . .
"1000501" "2020" 1 . 0
"1000502" "2017" . 0 .
"1000502" "2018" . . .
"1000502" "2019" . . .
"1000502" "2020" 0 . 0
"1000503" "2017" . 0 .
"1000503" "2018" . . .
"1000503" "2019" . . .
"1000503" "2020" 1 . 1
"1000701" "2017" . 1 .
"1000701" "2018" . . .
"1000701" "2019" . . .
"1000701" "2020" 1 . 0
"1000702" "2017" . 1 .
"1000702" "2018" . . .
"1000702" "2019" . . .
"1000702" "2020" 1 . 0
"1000703" "2017" . 0 .
"1000703" "2018" . . .
"1000703" "2019" . . .
"1000703" "2020" 0 . 0
"1002601" "2017" . 0 .
"1002601" "2018" . . .
"1002601" "2019" . . .
"1002601" "2020" 0 . 0
"1004203" "2017" . 1 .
"1004203" "2018" . . .
"1004203" "2019" . . .
"1004203" "2020" 1 . 1
Appreciate your help and thanks in advance
Related Posts with Creating new variable (subtracting) same individual
tsappendCan we do tsappend with some formula. Suppose we have yearly time series up to 2019. I extend 4 obse…
Two way area - lines get "thin" as they move upExample code: Code: set obs 200 gen indicator = uniform()<=0.5 gen y = _n twoway (area indicator…
Probability distribution histogram - binomialHello, In case of binomial probability, where n = 100 and p= 0.6. I would like to compute binomial p…
Need help in coding (Factorial Survey Method)Hello everyone. This is my first post in this forum. I am having a problem running the code for a re…
Random Stata glitchesI'm working with a dataset of ~1000 variables and ~5000 observations. Whenever I try to do my analys…
Subscribe to:
Post Comments (Atom)
0 Response to Creating new variable (subtracting) same individual
Post a Comment