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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: AW: r(198) error with a foreach loop - problem with '`'


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: r(198) error with a foreach loop - problem with '`'
Date   Thu, 29 Apr 2010 13:26:41 +0200

<> 

This code does work, though:

*************
foreach w in a{
		u "C:\Program Files (x86)\Stata11\ado\base/a/`w'uto.dta",
clear
}
*************

I strongly suspect you want the contents of a -local- "d" for the loop
instead of only the letter "d"?


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Jamie Fagg
Gesendet: Donnerstag, 29. April 2010 13:18
An: statalist@hsphsun2.harvard.edu
Betreff: st: r(198) error with a foreach loop - problem with '`'

Dear Statalist,

Firstly, thanks to Nick Cox and Austin Nichols for their reply to my
recent question about -esttab-. Both answers provide helpful clues to
where I should be going with the problem, but both also raised some
extra questions which I haven't had a chance to work through yet.

On a separate note, Stata is suddenly telling me that ` is not valid
in my foreach loops and I cannot work out where to look to identify
the problem. Code illustrating the issue is below.

Thanks

Jamie

//show that file exists
. use Work\Datasets\Source\dyouth,clear

. des, short

Contains data from Work\Datasets\Source\dyouth.dta
 obs:           773
vars:           101
size:        98,171 (99.9% of memory free)
Sorted by:

//show error with foreach loop
. foreach w in d {
 2.         use Work\Datasets\Source\`w'youth,clear
 3. }
invalid '`'
r(198);

end of do-file

r(198);


Thanks

Jamie

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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