Statalist


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

Re: st: Looping for dictionary file


From   Joseph Coveney <[email protected]>
To   Statalist <[email protected]>
Subject   Re: st: Looping for dictionary file
Date   Fri, 28 Sep 2007 11:01:13 -0700

Sorry about suggesting putting the cart before the horse. It was supposed
to be:

clear *
local dict D:/Paper/country.dct
local outfile D:/Paper/country.dta
save `outfile', emptyok
. . .


Something else to consider: Stata often has default file name extensions
that you can take advantage of, for example, .dct for dictionary files and
.dta for Stata dataset files. So, if the files are along the same path as
in your case, then you can get away with defining only one local macro
variable for both country.dct and country.dta, as in:

clear *
local file D:/paper/country
save `file', emptyok
forvalues i = 1/10 {
infile using `file' if level==2, using(D:\Data\state`i'.txt) clear
append using `file'
save `file', replace
}
sort fsu hamgroup sstratum hldno
save `file', replace
exit

If you're just starting out with Stata, then it might be better to make
everything explicit, however. (Being explicit will help make the code easier to maintain, too.)

Finally, it's not likely to make much difference in this problem, but look
into using temporary files for intermediate I/O work, see -tempfile-.

Joseph Coveney


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