Statalist The Stata Listserver


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

Re: st: duplicated observations when appending several files


From   [email protected]
To   [email protected]
Subject   Re: st: duplicated observations when appending several files
Date   Mon, 18 Jun 2007 17:23:23 +0200

dear Friedrich,
I run the routine you suggested and you were right: each observation does not 
appear only once across the 66 datasets (despite who provided the data was 
claiming the contrary!)
thank you very much for your help
Mariarosaria

Citazione Friedrich Huebler <[email protected]>:

> Mariarosaria,
> 
> First, change the path delimiter from a backward slash to a forward
> slash. In other words, instead of c:\data\ write c:/data/.
> 
> Second, are you sure that each observation appears only once across
> all 66 datasets? Run your merge and note the number of observations in
> the final file. Then add up the observations across the 66 files with
> the following commands. If the result is different you confirmed that
> at least one file is appended more than once. If the result is
> identical, the observations are not unique across the 66 files.
> 
> local filelist: dir "c:/data/" files "v*.dta"
> local n = 0
> foreach file of local filelist {
>   describe using "c:/data/`file'", short
>   local n = `n' + r(N)
> }
> di `n'
> 
> Friedrich
> 
> On 6/11/07, [email protected] <[email protected]> wrote:
> >
> > Dear all,
> > I have a problem when I append a list of files (named from v2.dta to
> v66.dta)
> > to the current dataset (v1.dta). Incidentally, all these files contain
> the
> > same variables, in the same order.
> > The command I use is the following:
> >
> > **************************************
> > use c:\data\v1
> > forvalues i = 2(1)66 {
> > append using "c:\data\v`i'"
> >
> >           }
> > **************************************
> >
> > when I look at the data in the resulting dataset many observations are
> > duplicated, as Stata had appended twice the same file. I have also tried
> to
> > use the alternatives:
> >
> > **************************************
> > foreach file in v2.dta v3dta v4.dta��.v66.dta {
> >                 append using "`file'"
> >         }
> > **************************************
> >
> > and:
> >
> > **************************************
> > local i = 1
> >         use c:\data\v`i', clear
> >         while `i'<=66 {
> >                 append using c:\data\v`i'
> >                 local i = `i' + 1
> >         }
> > **************************************
> >
> > but I always get the same strange result.
> > Thank you in advance for any suggestions
> >
> >
> > Mariarosaria
> 
> *
> *   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/
> 




-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index