For an ongoing project for the European Commission, I have to run some panel data regressions. Not so uncommon, isn’t it? After the panel regressions and if you are dealing with an unbalanced panel dataset, you might be interested to know which countries and periods are included in your estimation sample. I found a pretty neat trick on the Stata Forum. You can use the following code snippets to know which countries and periods are involved in your estimation, I have 36 countries and 16 periods in my case:

cap drop used
cap drop tag
bysort country: egen used = max(e(sample))
egen tag = tag(country)
list country if tag & used!=0

cap drop used
cap drop tag
bysort period: egen used = max(e(sample))
egen tag = tag(period)
list period if tag & used!=0

That’s it for today!