Hi All,
Could you please help how I can identify the first observation for a variable in a panel data? I use the following code:
It somehow works, but for countries that have no observation at all, it will not be included in the list. How can I include these countries, probably with label N/A. Is there a better way to find the first observation, if I have several variables? Also, is there are a way to identify the last observation? Thank you.
Best,
Abdan
Could you please help how I can identify the first observation for a variable in a panel data? I use the following code:
Code:
by country (quarter), sort: gen byte first = TOT != . by country (quarter), sort: gen byte firstobs = sum(first) == 1 list country quarter if firstobs==1
Best,
Abdan
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long country float quarter str6 date str18 Country int CountryCode double TOT byte(first firstobs) 1 116 "1989Q1" "Albania" 914 . 0 0 1 117 "1989Q2" "Albania" 914 . 0 0 1 118 "1989Q3" "Albania" 914 . 0 0 1 119 "1989Q4" "Albania" 914 . 0 0 1 120 "1990Q1" "Albania" 914 . 0 0 end format %tq quarter label values country country label def country 1 "Albania", modify
Comment