Dear Stata users,
I have an unbalanced panel data set with the following variables: id, year, nobirths, type.
I want to estimate how many hospitals (id) closed if the number of births in that year was less than 300 and the type of hospitals that closed. I do not want to consider for my estimation hospitals of type==1.
In order to do that I am using the following code:
xtset id year
tsfill, full (in order to balance the panel)
gen type2=type[_n-1]
tab nobirths type2 if nobirths[_n-1]<300&year==2014&type[_n-1]!=.&nobirths[_n-1]>0|nobirths[_n-1]<300&year==2014&type2[_n-1]!=1&nobirths[_n-1]>0, missing
However, when I obtain the table, it lists type2==1. I can see that it is because when Stata does "gen type2=type[_n-1]" is only considering the previous observation and not considering that I have panel data. Could anyone help me with a better solution?
Related Posts with Identify missing observations unbalanced panel
Stata speed when using i7 vs. i9 (vs. perhaps Xeon)Hello all, if I keep RAM constant at around 32GB, what sort of speed increase in Stata analysis (say…
Creating a new variable based on frequency of string values in varlistThis might be a basic question but I've been trying to create a variable to count the frequency of s…
Industry Dummy Variables - Grouping them togetherDear All, I have a panel data set that contains around 150 companies, covering a period of 15 years…
Business CalendarHey everybody, I'm trying since a long while to change my daily data to business calendar data. Acco…
Course: Practical use of multiple imputation to handle missing data in Stata. London, 25–26 Feb 2020We will next run our 2-day course on “Practical use of multiple imputation to handle missing data in…
Subscribe to:
Post Comments (Atom)
0 Response to Identify missing observations unbalanced panel
Post a Comment