1. Within each record "personid" I would like to compute "total episodes of homes in each year", where each record is a unique episode = "tot_episode_YEAR"
2. I also would like to compute the total number of unique home types for each individual in each year: 2015;2016 etc = "tot_home_type" and values appear in each row of data. This is based on "home_type"
See below the final output and variables:
personid | date_episode | home_type | tot_episode_YEAR | tot_home_type |
1 | 4-Nov-15 | rough | 2 | 1 |
1 | 20-Nov-15 | rough | 2 | 1 |
1 | 23-Feb-16 | transit | 3 | 2 |
1 | 23-May-16 | episodic | 3 | 2 |
1 | 6-Nov-16 | transit | 3 | 2 |
1 | 10-Mar-17 | private | 4 | 4 |
1 | 6-Jun-17 | rough | 4 | 4 |
1 | 9-Aug-17 | transit | 4 | 4 |
1 | 15-Dec-17 | private | 4 | 4 |
2 | 6-Jun-15 | transit | 2 | 2 |
2 | 8-May-15 | private | 2 | 2 |
2 | 6-Nov-16 | rough | 1 | 1 |
0 Response to New variables using longitudinal data
Post a Comment