Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: issue with forvalues/foreach

From   "Rubil Ivica" <>
To   <>
Subject   st: issue with forvalues/foreach
Date   Thu, 13 Dec 2012 17:21:18 +0100

Dear Statalisters:

When I to run the following (two artificial examples just to illustrate
the issue)

forvalues i = 1(1)30 {
	use "F:\project\data\dataset_`i'.dta", clear
	compress var1 var2
	save "F:\project\data\dataset_`i'.dta", replace

or for instance

foreach country in croatia albania {
	use "F:\project\data\dataset_`i'.dta", clear
	compress var1 var2
	save "F:\project\data\dataset:`i'.dta", replace

Stata returns

file F:\project\data`i'.dta not found

It seems strange to me that Stata "forgets" the exactly specified path:
"F:\project\data\dataset_`i'.dta" in the first example 
"F:\project\data\dataset_`i'.dta" in the second example.

Ivica Rubil
Ekonomski institut || The Institute of Economics, Zagreb
Trg J. F. Kennedyja 7, 10 000 Zagreb, Croatia
tel. +385-1-2362-269 || fax. +385-1-2335-165 ||

*   For searches and help try:

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