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

st: infiling a series of ASCII files

From   "Sascha O. Becker" <>
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:


and want to read them in using one and the same dictionary.

I have a do-file ( 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" {

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"


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
Fax +49 (89) 39 73 03
* For searches and help try:

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