Hi guys,
My problem is the following:
Data
My approaches to build a loop did not yield the expected results, so I would be happy if anybody could give me some creative input.
Thank you,
Carlos
My problem is the following:
Data
- I have panel data sorted by company_id and month_id
- Let us assume I have only one more variable, var1
- Example: see table below
- On a monthly basis, I would like to check whether there have been at least 10 non-missing observations of var1 within the past 20 months in order to drop those
- Although most observations follow month on month, there might be a gap of several years between some observations of var for a company_id
- Var1 can be existing or missing, month_ids might jump by several months/years which indicates that data in between is missing
company_id | month_id | var1 | data_availability [10 out of 12 past months] |
... | ... | ... | ... |
1 | 1988m1 | 5 | yes |
1 | 1988m2 | . | yes |
1 | 1998m3 | 4 | yes |
1 | 1995m10 | 6 | no |
1 | 1995m11 | 7 | no |
2 | 1987m1 | 5 | yes |
2 | 1987m2 | 5 | yes |
2 | 1989m5 | 8 | no |
2 | 1989m6 | . | no |
My approaches to build a loop did not yield the expected results, so I would be happy if anybody could give me some creative input.
Thank you,
Carlos
Comment