Good morning,
I'm working on a longitudinal dataset and I need to randomly assign cases to groups in the first wave. Basically, in the first wave, within each country separately (this because the distribution of cases across groups will be based on different percentages) and only at specific levels of education I have to assign the cases randomly specifying the percentage of observations I want to assign to each group.
In this hypothetical example I want to randomly assign 60% of cases belonging to wave 1, country 110 and having education 4 to group 2; while the remaining 40% have to go in the group 3 (there will be a total of 4 groups - so 0% goes to 1 and 4):
I'm working on a longitudinal dataset and I need to randomly assign cases to groups in the first wave. Basically, in the first wave, within each country separately (this because the distribution of cases across groups will be based on different percentages) and only at specific levels of education I have to assign the cases randomly specifying the percentage of observations I want to assign to each group.
In this hypothetical example I want to randomly assign 60% of cases belonging to wave 1, country 110 and having education 4 to group 2; while the remaining 40% have to go in the group 3 (there will be a total of 4 groups - so 0% goes to 1 and 4):
id | wave | country | education | group |
1 | 1 | 220 | 4 | . |
2 | 2 | 110 | 4 | . |
3 | 1 | 110 | 5 | . |
4 | 1 | 110 | 4 | 2 |
5 | 1 | 110 | 4 | 3 |
6 | 1 | 110 | 4 | 2 |
7 | 1 | 110 | 4 | 2 |
8 | 1 | 110 | 4 | 3 |
9 | 1 | 110 | 4 | 2 |
10 | 1 | 110 | 4 | 2 |
11 | 1 | 110 | 4 | 2 |
12 | 1 | 110 | 4 | 3 |
13 | 1 | 110 | 4 | 3 |
14 | 1 | 110 | 4 | 2 |
15 | 1 | 110 | 4 | 3 |
Comment