Hello, statalist!
I am struggling with the replace the value for the same person.
In the dataset, there are two observations, but they are the same person.
I do not want to drop duplicates but just replace the value which is shown as "SAME AS~" with the value.
Since ID=1 and ID=2 is the same person, name, mothername, fathername, and gender is the same.
But, they have different value in birthyear and birthmonth.
I have no idea how to do it.
Do I have to detect all of duplicates and replace it?
So, I was trying
code:
duplicates list name mothername fathername gender
but after then, I do not have any good idea to deal with this.
I want ID=2 to have same value as ID=2 in birthyear and birthmonth because their name, mothername, fathername, and gender is the same (which means same person)
So.. if two observations have the same value in name, mothername, fathername, and gender, then replace the birthyear and birthmonth with the same value as the other one.
Is it fast to replace "SAME AS~" with the blank?
==========================================data==== ===
ID name mothername fathername gender birthyear birthmonth
1 XXX ABC DEF female "1991" "9"
2 XXX ABC DEF female "SAME AS ID=2" "SAME AS ID=2"
3 AAA EFG GED male "1980" "5"
4 BBB FGH HBE female "1960" "3"
.
.
.
================================================== ==
I would greatly appreciate it if you give me any solution for this!
Thank you in advance.
Related Posts with Same value for duplicates
Calculating 5-year compound annual growth rate (CAGR) with missing valuesHi All, I'm trying to calculate the 5-year compound annual growth rate, which is "(endvalue/beginni…
How to create a plot showing the results of an OLS regressionDear all, I ran a panel regression taking the form of y = x1 +x12 + other control variable using …
List of long string varsI am simply looking to get a list of all the different values of a string variable, but some of them…
Lasso error message "error in postselection b"Hi everyone, I encountered this error when I was running the Lasso, "error in postselection b". Co…
Generating a variable for user pre and post policy changeHI, So I have panel data for 5 years (4,5,6,7,8) and I am evaluating a policy change that happened …
Subscribe to:
Post Comments (Atom)
0 Response to Same value for duplicates
Post a Comment