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]
RE: st: Problem in appending data files : an error happened
From
"David Radwin" <[email protected]>
To
<[email protected]>
Subject
RE: st: Problem in appending data files : an error happened
Date
Tue, 6 Nov 2012 08:31:22 -0800 (PST)
Try this before -append-ing:
. tostring m12b, replace
David
--
David Radwin
Senior Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794
www.mprinc.com
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Amir Kasaeian
> Sent: Tuesday, November 06, 2012 8:19 AM
> To: [email protected]
> Subject: Re: st: Problem in appending data files : an error happened
>
>
> Dear all,
> I encountered a new error in appending my data with the below codes.
> I received the following error about one of my variables.
>
> ""m12b is str5 in using data""
>
> and I do not know how to resolve it.
>
> Many thanks your help in advance.
> Best,
> Amir
>
>
>
> ________________________________
> From: Maarten Buis <[email protected]>
> To: [email protected]
> Sent: Tuesday, 6 November 2012, 17:39
> Subject: Re: st: Problem in appending data files.
>
> replace province=`i'
>
> should be
>
> replace province=`i' if province == .
>
> -- Maarten
>
> On Tue, Nov 6, 2012 at 3:07 PM, Maarten Buis <[email protected]>
> wrote:
> > use "C:\Total85\S0.dta"
> > gen province = 0
> > forvalues i= 1/29 {
> > append using "C:\Total85\S`i'.dta" ,
> > replace province=`i'
> > }
> > save "C:\Total85\Total.dta", replace
> >
> > -- Maarten
> >
> > On Tue, Nov 6, 2012 at 2:46 PM, Amir Kasaeian
<[email protected]>
> wrote:
> >> Dear all,
> >> Good day!
> >> I have a problem in appending my data files.
> >> I wrote a loop but there is little problem that I don't know how to
> resolve it.
> >> Your help will be appreciated.
> >> I use stata MP 11.
> >> The problem is that I have 30 files in a folder named S0 through S1.
I
> want to have a final file named for example "Total" including a new
> variable as an indicator for observations of each of 30 separate files.
> >> I wrote my file as :
> >>
> >> forvalues i= 0/29 {
> >> append using "C:\Total85\S`i'.dta" ,
> >> gen Province=`i'
> >> save "C:\Total85\Total.dta", replace
> >> }
> >>
> >>
> >> but the code stops at the first step alarming:
> >>
> >>
> >> . do "C:\Users\AK\AppData\Local\Temp\STD00000000.tmp"
> >>
> >> . forvalues i= 0/29 {
> >> 2. append using "C:\Total85\S`i'.dta" ,
> >> 3. gen Province=`i'
> >> 4. save "C:\Total85\Total.dta", replace
> >> 5. }
> >> file C:\Total85\Total.dta saved
> >> Province already defined
> >> r(110);
> >>
> >> end of do-file
> >>
> >> r(110);
> >>
> >>
> >> The Total file just includes observation from the S0.
> >> Would you please help me to modify my codes?
> >> Bunch of thanks,
> >> Amir
> >>
> >> *
> >> * For searches and help try:
> >> * http://www.stata.com/help.cgi?search
> >> * http://www.stata.com/support/faqs/resources/statalist-faq/
> >> * http://www.ats.ucla.edu/stat/stata/
> >
> >
> >
> > --
> > ---------------------------------
> > Maarten L. Buis
> > WZB
> > Reichpietschufer 50
> > 10785 Berlin
> > Germany
> >
> > http://www.maartenbuis.nl
> > ---------------------------------
>
>
>
> --
> ---------------------------------
> Maarten L. Buis
> WZB
> Reichpietschufer 50
> 10785 Berlin
> Germany
>
> http://www.maartenbuis.nl
> ---------------------------------
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
>
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/