Hello everyone,
I have dataset like this,
ID value1 value2 value3 ....
1 10 20 30
1 20 20 30
1 40 20 30
2 10 50 80
2 30 50 80
3 40 30 90
3 50 30 90
. . . .
. . . .
. . . .
As you can see, only the value of var1 is different, and the values of var2 and var3 are all the same.
I want to make my data file like this.
ID value1 value2 value3 ....
1 70 20 30
2 40 50 80
3 90 30 90
value1 is the sum of value1 per ID, and value2 and value3 are fixed values.
I tried to use the duplicates and the egen function, but it did not work and I have no idea anymore.
Is there anyone you can give me a hint about?
Thanks in advance.
HS Jang from South Korea
Related Posts with Sum by ID in one data file
Problem wtih running and exporting first and second stage regressions with ivregress2 an getting the cluster standard errorHello, I am using ivregress2 to run and export the results of first and second stage regressions. I…
Renaming with renumbering Code: * Example generated by -dataex-. For more info, type help dataex clear input byte v1 str19 st…
Problem wtih running and exporting first and second stage regressions with ivregress2 and getting the cluster standard errorHello, I am using ivregress2 to run and export the results of first and second stage regressions. I…
Help identifying namesDear all, I have a database with over forty thousand observations and I want to identify if the pers…
Bysort TroubleHello, I am attempting to execute a very simple command where I create a new variable for each id (…
Subscribe to:
Post Comments (Atom)
0 Response to Sum by ID in one data file
Post a Comment