Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: help expanding the dataset by n observations


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: help expanding the dataset by n observations
Date   Fri, 24 Nov 2006 16:02:50 -0000

Good. My advice was even better... 

Nick 
n.j.cox@durham.ac.uk 

Scott Cunningham
 
> Yes, what I proposed worked.
> 
> I am once again impressed by how much easier my life is with - 
> reshape-.  Very simple solution, if you can even call it that, but I  
> was mapping out much more convoluted solutions and so I am glad for  
> that reshape command.
> 
> 
> On Nov 24, 2006, at 10:33 AM, Nick Cox wrote:
> 
> > Maarten Buis recommended a book for you to buy
> > and I can endorse that. In fact, it is so good
> > you should have one for home and one for work.
> > Perhaps even three, because someone will walk
> > away with one and you'll never see it again.
> >
> > In the mean time, here is one approach to
> > what I understand to be your problem.
> >
> > 1. Add a pseudo-county to the end of your data
> > with the missing years. Use an -fip- already
> > used. You can do this in -edit-.
> >
> > county   fip year
> >
> > 9999     1  1983
> > ...
> > 999      1  2004
> >
> > 2. Now fill in using
> >
> > fillin county year
> >
> > 3. Now -drop- the observations for the pseudo-county.
> > It never existed anyway.
> >
> > Nick
> > n.j.cox@durham.ac.uk
> >
> > Scott Cunningham
> >
> >> I have the following dataset on county-level data.  VBL is a dummy
> >> indicating whether an object is present in the county.  COUNTY is a
> >> number greater than 0 indicating which United States 
> county is being
> >> described, and FIP is indicating which US state.
> >>
> >>
> >>        +-----------------------------+
> >>        | county   fip   year   vbl |
> >>        |-----------------------------|
> >>     1. |      1     1   1980       0 |
> >>     2. |      1     1   1981       0 |
> >>     3. |      1     1   1982       0 |
> >>     4. |      1     1   1984       0 |
> >>     5. |      1     1   1985       0 |
> >>        |-----------------------------|
> >>     6. |      1     1   1987       1 |
> >>     7. |      1     1   1988       1 |
> >>     8. |      1     1   1991       1 |
> >>     9. |      1     1   1992       1 |
> >> 10. |      1     1   1995       1 |
> >>        |-----------------------------|
> >> 11. |      1     1   1996       1 |
> >> 12. |      1     1   1999       1 |
> >> 13. |      1     1   2000       1 |
> >>        +-----------------------------+
> >>
> >> As one can see, I am missing years 1983, 1986, 1989, 1990, 1993,
> >> 1994, 1997, 1998, and 2001-2004.  For each county/fip, I want to
> >> create 12 new observations which I can then use to fill in the
> >> missing years.  I can do the filling in, but I cannot find
> >> information for simply expanding this dataset by n observations.  I
> >> have searched for the answer, but -expand- takes me to various
> >> places, like -fillin-, neither of which seem appropriate.  Any help
> >> is appreciated.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index