Dear all,
I know that the title is confusing, but I had no idea how to better describe my issue.
So, I have the following dataset:
I would like to generate a new variable that would take different values, depending on the values from the group variable, per id.
So, if there are only -1, then the new variable will be 0 (or whatever number) for the respective person (in my example id 1 will have this value). If there are only 0 another number (id 2). If there are only -1 and 0 another number (id 5)... and so on.
Thank you,
Dimi
I know that the title is confusing, but I had no idea how to better describe my issue.
So, I have the following dataset:
id | group |
1 | -1 |
1 | -1 |
1 | -1 |
2 | 0 |
2 | 0 |
2 | 0 |
3 | 1 |
3 | 1 |
3 | 1 |
3 | 1 |
4 | -1 |
4 | 1 |
5 | -1 |
5 | 0 |
So, if there are only -1, then the new variable will be 0 (or whatever number) for the respective person (in my example id 1 will have this value). If there are only 0 another number (id 2). If there are only -1 and 0 another number (id 5)... and so on.
Thank you,
Dimi
Comment