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   Scott Cunningham <scunning@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: help expanding the dataset by n observations
Date   Fri, 24 Nov 2006 10:53:12 -0500

Nick,

I'm ordering the book after this post. Sounds like I need it, as I have large gaps in the basics of Stata, combined with more intermediate knowledge elsewhere. The book sounds like it'll fill out some of these gaps, at least.

As I was reading your post, I also wondered if it wouldn't be easier to use -reshape- to put the data in wideform. For instance, say the data is in the form below (bottom of message). I could create missing observations by first reshaping, generating the variables, and reshaping back.

. egen id=group(fip year)
. reshape wide vbl, i(id) j(year)
. gen vblXX=.
where XX is the missing year

And then reshape back. Maybe there is a more efficient way to accomplish this, but reshape will at least allow me to expand by n without too many headaches.



+-----------------------------+
| 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 0 |
7. | 1 1 1988 0 |
8. | 1 1 1991 0 |
9. | 1 1 1992 0 |
10. | 1 1 1995 0 |
|-----------------------------|
11. | 1 1 1996 0 |
12. | 1 1 1999 0 |
13. | 1 1 2000 0 |
14. | 3 1 1980 1 |
15. | 3 1 1981 1 |
|-----------------------------|
16. | 3 1 1982 1 |
17. | 3 1 1984 0 |
18. | 3 1 1985 0 |
19. | 3 1 1987 0 |
20. | 3 1 1988 0 |
|-----------------------------|
21. | 3 1 1991 0 |
22. | 3 1 1992 0 |
23. | 3 1 1995 0 |
24. | 3 1 1996 0 |
25. | 3 1 1999 0 |
|-----------------------------|
26. | 3 1 2000 0 |
+-----------------------------+

*
* 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