Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Renaming files


From   Rafal Raciborski <[email protected]>
To   Stata_list <[email protected]>
Subject   st: Renaming files
Date   Wed, 29 Dec 2004 22:16:55 -0500

Let's say I have data on imports to the U.S., commodity by country, on a yearly
basis (such as Feenstra's TSUSA Imports).  The original data are in txt format
and there are three txt files per year.  Assume file names are completely
random but all the files have identical layout (var names, type, etc.).

Now I want to infile the txt files into Stata, save them in dta format as
import1, import2, ... , import51...

forvalues i = 1(1)51 {
    infile using C:\Imports\import`i'.txt
    save import`i'
    clear
}

... and then I want to create one huge dataset:

use import1
forvalues i = 2(1)51 {
    append using import`i'
}
save import-big

However, before running the first loop, I have to rename manually all the 51 txt
files from whatever name to import1, import2, etc., which is a nuisance.  Is
there a way to automate this process either from Stata or directly from
Windows?  Something like ``rename all the files in folder X to import1,
import2, ...''

Many thanks and a Happy New Year to everybody.

rafal

================
Rafal Raciborski
Graduate student
Department of Political Science
Emory University
301 Tarbutton Hall
1555 Dickey Drive
Atlanta, GA 30322
404-378-9826 (home)
[email protected] (e-mail)
www.roofoos.net

*
*   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