Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Problem in appending data files : an error happened |

Date |
Tue, 6 Nov 2012 18:33:51 +0000 |

There is, I guess, a clash between datasets in variable type. Perhaps -m12b- is numeric elsewhere. You may need to apply -destring- before you can combine that dataset with others. On Tue, Nov 6, 2012 at 4:18 PM, Amir Kasaeian <amir_kasaeian@yahoo.com> wrote: > 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. From: Maarten Buis <maartenlbuis@gmail.com> > replace province=`i' > > should be > > replace province=`i' if province == . On Tue, Nov 6, 2012 at 3:07 PM, Maarten Buis <maartenlbuis@gmail.com> 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 On Tue, Nov 6, 2012 at 2:46 PM, Amir Kasaeian <amir_kasaeian@yahoo.com> wrote: >>> 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. * * 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/

**References**:**st: Problem in appending data files.***From:*Amir Kasaeian <amir_kasaeian@yahoo.com>

**Re: st: Problem in appending data files.***From:*Maarten Buis <maartenlbuis@gmail.com>

**Re: st: Problem in appending data files.***From:*Maarten Buis <maartenlbuis@gmail.com>

**Re: st: Problem in appending data files : an error happened***From:*Amir Kasaeian <amir_kasaeian@yahoo.com>

- Prev by Date:
**st: How to interpret results from gllamm** - Next by Date:
**Re: st: How to interpret results from gllamm** - Previous by thread:
**RE: st: Problem in appending data files : an error happened** - Next by thread:
**st: RE: Problem in appending data files.** - Index(es):