Hello,
I have a panel of banks from year 1905 to 1910. Some banks have observations for the whole duration of the panel, some fail before the end of the panel (i.e. last observation in year 1907), some are founded after the beginning of the panel (i.e. first observation in 1906).
Each bank has a unique Id. My time measure is years.
I want to create a dummy variable called "disappear" - if a bank disappears before the end of the panel.
The code I have so far is:
gen disap = 0
sort Id_Bank Year
bys Id_Bank (Year): replace disap = 1 if & Year[_N]<1910
But I am not sure this does what I want - is this the correct way of creating the dummy?
A separate question: what if I wanted to *not* include banks that are founded after 1907, even if they fail before 1910? what code should I use in that case?
Thank you very much for your help.
Beatrice
Related Posts with Generate dummy if last observation for an individual in panel occurs before time x
Is it possible to "export delimited" with variable labels instead of variable names?Dear Statalisters, I'm quite new to Stata and I've run into what seems like a very "basic" problem.…
Event Study - Loop for calculating CARsHello everyone. I am trying to do a loop to calculate CARs (Cumulative Abnormal returns) for an Eve…
Oaxaca decomposition (nledcompose): how to deal with categorical Y'sDear all, I am new to the Oaxaca-Blinder decomposition, and I'ld like to know your opinion about ho…
Label variable over multiple linesI want to label multiple variables in my dataset in one command, like below: lab var /// id "ID" //…
filling missing data per id from cells below.Dear Stata Community, I am working with long panel data. I have multiple observations per id. In m…
Subscribe to:
Post Comments (Atom)
0 Response to Generate dummy if last observation for an individual in panel occurs before time x
Post a Comment