Hi everyone,
I have a hierarchical dataset with more than 70,000 episodes (level 3 variable) that could be grouped by ID (level 1 variable). Within each ID there are cases consisting of different numbers of related episodes. Multiple is a variable that counts the number of episodes within a particular case and is what I mean by level 3 variable (my dataset looks like below). I need to create a level 2 variable (new variable) that counts the number of cases by unique number. Is there any solution?
Ideally, I need to count these unique cases within ID group and take into account missing values which are simply cases with 1 episode. So to create this new variable 2:
Thank you!
Kind regards,
Svetlana
I have a hierarchical dataset with more than 70,000 episodes (level 3 variable) that could be grouped by ID (level 1 variable). Within each ID there are cases consisting of different numbers of related episodes. Multiple is a variable that counts the number of episodes within a particular case and is what I mean by level 3 variable (my dataset looks like below). I need to create a level 2 variable (new variable) that counts the number of cases by unique number. Is there any solution?
ID | multiple | new variable |
id1 | ||
id1 | 1 | 1 |
id1 | 2 | 1 |
id2 | ||
id2 | ||
id2 | 1 | 2 |
id2 | 2 | 2 |
id2 | 1 | 3 |
id2 | 2 | 3 |
id2 | 3 | 3 |
id3 | ||
id3 | ||
id3 | ||
id3 | ||
id4 | ||
id4 | 1 | 4 |
id4 | 2 | 4 |
id4 | 3 | 4 |
id4 | 4 | 4 |
id4 | 1 | 5 |
id4 | 2 | 5 |
Ideally, I need to count these unique cases within ID group and take into account missing values which are simply cases with 1 episode. So to create this new variable 2:
ID | multiple | new variable | new variable 2 |
id1 | 1 | ||
id1 | 1 | 1 | 2 |
id1 | 2 | 1 | 2 |
id2 | 1 | ||
id2 | 2 | ||
id2 | 1 | 2 | 3 |
id2 | 2 | 2 | 3 |
id2 | 1 | 3 | 4 |
id2 | 2 | 3 | 4 |
id2 | 3 | 3 | 4 |
id3 | 1 | ||
id3 | 2 | ||
id3 | 3 | ||
id3 | 4 | ||
id4 | 1 | ||
id4 | 1 | 4 | 2 |
id4 | 2 | 4 | 2 |
id4 | 3 | 4 | 2 |
id4 | 4 | 4 | 2 |
id4 | 1 | 5 | 3 |
id4 | 2 | 5 | 3 |
Thank you!
Kind regards,
Svetlana
Comment