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
Why does indicating omitted dummy variables not work?So I run two Probit regressions with different commands, one is with i(2 3 4 5).c_lable and the othe…
Nested loops with macros - using required, r(100)Hi everyone, I have about twenty csv files on which I need to do some estimation after I have obtai…
defining group numbersDear All, I found this question here (https://bbs.pinggu.org/thread-7407152-1-1.html). The data is …
How to generate a value for groups of distinct value of a variable and then drop subgroups based on the value generated?Hi! I have a dataset including ppl's information in the group of family (each observation has a pid …
Creating interaction terms of country and period fixed effectsDear all, I had a general question regarding the construction of interaction terms using country an…
Subscribe to:
Post Comments (Atom)
0 Response to Identify missing observations unbalanced panel
Post a Comment