Dear stata-users,
I'm currently building a dataset. My problem is that in some cases I have several observations (same ID) that I want to reduce to one oberservation that contains the information of the original observations. For dummies this would mean that the dummy of the new observation equals 1 if any of the original observations takes a 1. For texts I would like to have a field that combines all texts of the orginal observations.
My data looks like this:
I want it to look like this:
I though about reshape and to create a new variable but I have many variables in the dataset and didn't know how to handle the different numbers of observations with the same ID.
Any suggestions are very welcome.
Sven
I'm currently building a dataset. My problem is that in some cases I have several observations (same ID) that I want to reduce to one oberservation that contains the information of the original observations. For dummies this would mean that the dummy of the new observation equals 1 if any of the original observations takes a 1. For texts I would like to have a field that combines all texts of the orginal observations.
My data looks like this:
ID | dum_1 | text_1 |
1 | 0 | abc |
1 | 1 | def |
1 | 1 | ghi |
2 | 0 | jkl |
2 | 0 | mno |
3 | 1 | pqr |
4 | 0 | stu |
I want it to look like this:
ID | dum_1 | text_1 |
1 | 1 | abc;def;ghi |
2 | 0 | jkl;mno |
3 | 1 | pqr |
4 | 0 | stu |
I though about reshape and to create a new variable but I have many variables in the dataset and didn't know how to handle the different numbers of observations with the same ID.
Any suggestions are very welcome.
Sven
Comment