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
Listing values and labelsI have a bunch of countries. They are coded as numbers (values) in an integer variable. For each val…
confidence interval for mean differenceDear Listers, I would like to know how to capture confidence interval for mean difference. I have …
Time-series analysisHello everyone! I want to create a graph base on several rounds of ESS survey years. I have immigra…
Running regressions in a loopHi all, I have got a large dataset available which has 14 yearly datapoints for several independent…
Time Series RegressionHi all, I'm working on the following sample. Code: * Example generated by -dataex-. To install: s…
Subscribe to:
Post Comments (Atom)
0 Response to Creating new variable (subtracting) same individual
Post a Comment