Statalist The Stata Listserver

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

Re: st: loop over file names

From   "Sebastian F. Büchte" <>
Subject   Re: st: loop over file names
Date   Tue, 6 Jun 2006 18:30:52 +0200


you must take care that you start with an empty dataset before you
make use of insheet. This could be a possible reason for the failure
of the insheet command. However, it would be generally helpful if you
could provide some of the output including the error message.


On 6/6/06, Wanli Zhao <> wrote:
I just cannot find the old thread about this.
I have some files called 1993.txt ... 2003.txt.

1. I want to insheet the files by "foreach" or "forvalues".
If I do:
forvalues i of 1993(1)2003 {
insheet using c:\`i'.txt
It is not working. I also tried other ways and cannot figure how. Invalid

2. within each file processing, I need to do "gen year=`i'"

3. after the processing, I need to save the file as ...\`i'.dta.

I am obviously stuck at the "insheet" step but maybe I need to change 2 and
3 also? I appreciate your help. Thanks.


*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2022 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index