[
Date Prev
][
Date Next
][
Thread Prev
][
Thread Next
][
Date index
][
Thread index
]
st: infiling a series of ASCII files
From
"Sascha O. Becker" <
[email protected]
>
To
[email protected]
Subject
st: infiling a series of ASCII files
Date
Thu, 17 Jun 2004 15:47:27 +0200
Dear Stata listers,
I have a series of ASCII files that have names carrying the year and month as part of their names:
myfile_1999_01.txt
myfile_1999_02.txt
...
myfile_2002_12.txt
and want to read them in using one and the same dictionary.
I have a do-file (mydata.do) in which I loop year and month
***
foreach year in 1999(1)2002 {;
foreach month in 1(1)12 {;
infile using mydict.dct, clear;
save "$root\Data\myfile_`year'_`month'.dta", replace;
};
};
***
In order to call the correct ASCII files, I need to adress them in my *.dct file (mydata.dct) in the first line.
+++++
Using locals does not work:
dictionary using "myfile`year'_`month'.txt" {
STUFF
}
because Stata does not carry them over to the *.dct file.
+++++
So, I thought, I'd use macros and add the following line to the above loop:
global year "`year'"
global month "`month'"
and then call them in my *.dct file
1) dictionary using "myfile_$year_$month.txt"
or
2) dictionary using "myfile_{$year}_{$month}.txt" {
but this does not work either.
Do you have any suggestions on this?
Best regards, Sascha Becker
--
Dr. Sascha O. Becker
Center for Economic Studies
University of Munich
Schackstr. 4 - 80539 Munich, Germany
Tel +49 (89) 2180-6252
http://www.lmu.de
Fax +49 (89) 39 73 03
[email protected]
*
* 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/
Follow-Ups
:
st: Re: infiling a series of ASCII files
From:
"Oleksandr Talavera, EUV" <
[email protected]
>
Prev by Date:
Re: st: Summer Stata Movies
Next by Date:
Re: st: merge and mmerge
Previous by thread:
[no subject]
Next by thread:
st: Re: infiling a series of ASCII files
Index(es):
Date
Thread
© Copyright 1996–2025 StataCorp LLC |
Terms of use
|
Privacy
|
Contact us
|
What's new
|
Site index