I have a dataset that looks like this:
pid | value | number |
1 | 0.12 | 2 |
1 | 0.4 | 2 |
1 | 0.3 | 2 |
1 | 0.01 | 2 |
2 | 0.2 | 3 |
2 | 0.321 | 3 |
2 | 0.15 | 3 |
2 | 0.4 | 3 |
In the case of the respondent 2 (id=2) I want Stata to create a dummy variable turning 1 in the three lowest values. So the result would be the following:
pid | value | number | newvar |
1 | 0.12 | 2 | 1 |
1 | 0.4 | 2 | 0 |
1 | 0.3 | 2 | 0 |
1 | 0.01 | 2 | 1 |
2 | 0.2 | 3 | 1 |
2 | 0.321 | 3 | 1 |
2 | 0.15 | 3 | 1 |
2 | 0.4 | 3 | 0 |
0 Response to How can I select more than one minimum for each respondent
Post a Comment