Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Unbalancing a panel data set with country pairs


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: Unbalancing a panel data set with country pairs
Date   Fri, 21 Jan 2011 13:39:48 +0000

I assume that "country pair" defines a panel identifier. 

Look at the help for -egen-, which gives you one way to start. 

In terms of missings, 

egen missing_in_obs = rowmiss(varlist)
egen missing_in_panel = total(missing_in_obs), by(panelid)
drop if missing_in_panel 

In terms of not enough years, you don't quite say what the time resolution of your data is. But assuming you have yearly observations then 

bysort panelid : drop if _N < 17 

drops the short panels. If it's half-years, quarters, months, etc. adjust as needed. 

You need to plug in your own <varlist> and <panelid>. 

The big concept you appear to be missing is that of working -by:-. There is a tutorial at 

SJ-2-1  pr0004  . . . . . . . . . . Speaking Stata:  How to move step by: step
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        Q1/02   SJ 2(1):86--102                                  (no commands)
        explains the use of the by varlist : construct to tackle
        a variety of problems with group structure, ranging from
        simple calculations for each of several groups to more
        advanced manipulations that use the built-in _n and _N

Nick 
[email protected] 

Matei Frunzetti

I 'm working on a panel data set over 17 years. It's fairly unbalanced  
und i need to drop all observations for country pairs that either lack  
full length (as in years) or have missings in one of the independant  
variables. The problem is that i have to delete all observations of  
these country pairs for all years if only one or more variables have a  
missing or if it is one or more years short. I ran into a dead end  
trying to figure out how to imply the rest of the observations of a  
"faulty" country pair into the drop command.


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index