Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Rubil Ivica" <irubil@eizg.hr> |
To | <statalist@hsphsun2.harvard.edu> |
Subject | RE: st: issue with forvalues/foreach |
Date | Fri, 14 Dec 2012 16:52:17 +0100 |
Billy, what you are saying is right, it should have worked before as well. I don't know why it didn't; I suppose I didn't replace all backslashes properly, according to your suggestion. Sorry for that. And thanks. Best, i -- 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 irubil@eizg.hr || www.eizg.hr -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of William Buchanan Sent: 14. prosinac 2012 16:40 To: statalist@hsphsun2.harvard.edu Subject: Re: st: issue with forvalues/foreach Hi Ivica, If replacing the "\" characters with "/" characters didn't work before (see previous post below), but is working now: "Thanks, Maarten, your suggestion works perfectly fine. So, I should change the obviously bad habit of using backslash instead of slash." You might have some other underlying problems, since it should have worked the first time as well. If you run into the same issue again in the future, you might want to consider emailing Tech Support to make sure there aren't any problems with the installation on your computer. HTH, Billy On Dec 13, 2012, at 8:36 AM, Rubil Ivica wrote: > William, what your suggested does not work either, even after > sustituting "/" for "\". > > > > > > -- > 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 > irubil@eizg.hr || www.eizg.hr > > > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of William > Buchanan > Sent: 13. prosinac 2012 17:28 > To: statalist@hsphsun2.harvard.edu > Subject: Re: st: issue with forvalues/foreach > > Hi Ivica, > > Try: > > forv i = 1/30 { > use `"F:/project/data/dataset_`i'"', clear > compress var1 var2 > save `"F:/project/data/dataset_`i'b"', replace > clear > } > > It's probably a good idea not to permanently modify your data files (so > adding "b" to the end of the filename should make it easier to > distinguish the two). Also notice the use of "/" instead of "\" in the > file path. Using the "/" character will work on all platforms, and > avoids some of the problems that you faced. > > HTH, > Billy > > > On Dec 13, 2012, at 8:21 AM, Rubil Ivica wrote: > >> 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 >> clear >> } >> >> 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 >> clear >> } >> >> 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 >> and >> "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 >> irubil@eizg.hr || www.eizg.hr >> >> >> * >> * For searches and help try: >> * http://www.stata.com/help.cgi?search >> * http://www.stata.com/support/faqs/resources/statalist-faq/ >> * http://www.ats.ucla.edu/stat/stata/ > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/