I have two data sets.
data set a with group level data for variables x, y, and group_id.
data set b with individual level data for variables a, b and group_id. This data has duplicates of group_id. I want to add together var_a if group_id is the same and add together var_b if group_id is the same. To transform individual level data into group level data so I can merge it with data set a.
current data set b
I want it to look like:
I have tried to gen and egen new variables but have not been able to get anything to work. Any code or even the command to look at would be appreciated.
data set a with group level data for variables x, y, and group_id.
data set b with individual level data for variables a, b and group_id. This data has duplicates of group_id. I want to add together var_a if group_id is the same and add together var_b if group_id is the same. To transform individual level data into group level data so I can merge it with data set a.
current data set b
group_id | var_a | var_b |
1 | 100 | 60 |
1 | 50 | 10 |
2 | 30 | 20 |
2 | 10 | 70 |
3 | 110 | 130 |
group_id | var_a | var_b |
1 | 150 | 70 |
2 | 40 | 90 |
3 | 110 | 130 |
Comment