T.J. Volant ([email protected]) asks about a file saving problem
in some code he wrote:
> I'm running a program through bunch of files(
> file1.dta, file2.dta, etc) I am opening them and would
> like to save them as replace. It opens fine, but
> saving doesn't work.
>
> My code:
>
> forv i=1(1)48 {
> use "C:\WINNT\Desktop\file`i'.dta"
>
> * body of the program *
>
> save "C:\WINNT\Desktop\file`i'.dta", replace
> clear
> }
>
> When it saves, it only saves file.data, not file1.dta,
> etc. Why?
Some others have speculated that the problem may be due to
backslashes or due to the directory in which TJ is saving the
file. From the code above, this is not the problem. The
only time a backslash is interpreted in a special way by
Stata is when it immediately preceeds a local (`) or global ($)
macro character.
Something in the body of the loop that we cannot see must be
clearing local macro i. This makes Stata see
save "C:\WINNT\Desktop\file.dta", replace
rather than
save "C:\WINNT\Desktop\file1.dta", replace
If TJ wishes to email [email protected], someone will help him
track down what is going wrong in his code.
Alan
([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/