Dear Stata users,
I have the following dataset
input id num1 num2 num3 num4 num5
1 12 1 14 55 15
1 12 1 14 145 15
2 99 9 97 4 96
2 99 9 97 23 96
2 99 9 97 200 96
3 55 3 4 3 22
end
I noted that the dataset contains some duplicate observations in terms of all variables but num4.
Therefore, I would like to collapse these duplicate observations into a single row by summing up the value of num4.
To illustrate the final dataset should consists of three rows as the following:
input id num1 num2 num3 num4 num5
1 12 1 14 200 15
2 99 9 97 227 96
3 55 3 4 3 22
end
I'm not sure what is the quickest way to do this. Can I kindly ask you to help me with this?
Thank you in advance.
Best regards,
F
I have the following dataset
input id num1 num2 num3 num4 num5
1 12 1 14 55 15
1 12 1 14 145 15
2 99 9 97 4 96
2 99 9 97 23 96
2 99 9 97 200 96
3 55 3 4 3 22
end
I noted that the dataset contains some duplicate observations in terms of all variables but num4.
Therefore, I would like to collapse these duplicate observations into a single row by summing up the value of num4.
To illustrate the final dataset should consists of three rows as the following:
input id num1 num2 num3 num4 num5
1 12 1 14 200 15
2 99 9 97 227 96
3 55 3 4 3 22
end
I'm not sure what is the quickest way to do this. Can I kindly ask you to help me with this?
Thank you in advance.
Best regards,
F
Comment