| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: RE: loop to fill in missing observations
Dear Nick and Carole,
Thank you very much for your help. Nick's code worked perfectly
(after fixing the typos).
I originally discarded the -merge- option because part of the problem
was to identify the gaps, and I thought that if I could do that then
it would be easier to directly fill them in.
I discarded the -fillin- option because no country has data for each
year. But I did not realize that -fillin- works if just one country
is completed, which is easily done.
Thanks again,
Fabrizio
On 15 Jun 2007, at 19:08, Nick Cox wrote:
Correct. Thanks for the catch.
My guess is also that a -fillin- approach at most needs
some extra observations being added. This is explained in
SJ-5-1 dm0011 . . . . . . . . . . . . . . Stata tip 17: Filling
in the gaps
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N
. J. Cox
Q1/05 SJ 5(1):135--136
(no commands)
tips for using fillin to fill in gaps in a rectangular
data structure
Nick
[email protected]
Carole J. Wilson
Fabrizio,
I think the replace commands should read:
replace countryn = `x' in l
replace year = `y' in l
(no double ==) in Nick's post.
--Carole
On 6/15/07, Nick Cox <[email protected]> wrote:
qui forval x = 1/28 {
forval y = 1975/2002 {
count if countryn == `x' & year == `y'
if r(N) == 0 {
set obs `= _N + 1'
replace countryn == `x' in l
replace year == `y' in l
}
}
}
*
* 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/
------------------------------------------------------------
Fabrizio Gilardi, PhD
Institut d'Etudes Politiques et Internationales
Universit� de Lausanne
B�timent Anthropole
CH-1015 Lausanne
Switzerland
Phone +41 21 692 31 48
Fax + 41 21 692 31 45
[email protected]
http://wwwpeople.unil.ch/fabrizio.gilardi/
------------------------------------------------------------
*
* 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/