Hi Everyone,
I am super new to Stata like 2 weeks, and I have a pretty big data set in which I need to keep different observations defined in different ranges. I was wondering how can I do it in one time but not every single one of them separately. Because if I use the keep command everything else is getting dropped and I do not want to start again for each observation. The data set looks like this
id . num_date sales
1 . 179
1 . 180
1 . 181
1 . 182
1 . 183
1 . 184
2 . 179
2 . 180
2 . 181
2 . 182
So I wanna keep the observations with num_date 180-184 for id 1, but 179-181 for the id 2. Is there a loop or anything I can create to make everything in one go? If not what is the most convenient way of doing it?
Thanks
I am super new to Stata like 2 weeks, and I have a pretty big data set in which I need to keep different observations defined in different ranges. I was wondering how can I do it in one time but not every single one of them separately. Because if I use the keep command everything else is getting dropped and I do not want to start again for each observation. The data set looks like this
id . num_date sales
1 . 179
1 . 180
1 . 181
1 . 182
1 . 183
1 . 184
2 . 179
2 . 180
2 . 181
2 . 182
So I wanna keep the observations with num_date 180-184 for id 1, but 179-181 for the id 2. Is there a loop or anything I can create to make everything in one go? If not what is the most convenient way of doing it?
Thanks
Comment