Macros constantly resulting in 'invalid name'

Mach picture Mach · Apr 16, 2014 · Viewed 14.4k times · Source

I'm a newcomer to Stata after using R for a long time.

I'm trying to perform any action which involves a macro, such as a loop and it is constantly giving me an invalid name r(198) error.

For example, when I first start up Stata, I enter the following code into the command prompt:

local hello 123
di 'hello'

This results in:

'hello' invalid name    
r(198);

Similarly, I try:

forvalues i=1/5 {
    display 'i'
}

Which results in the same invalid name error.

I'm obviously doing something fundamentally wrong. I have tried putting the same commands into a do file and running them, but the same thing occurred.

I was wondering if it's something to do with how I'm running the code as this link alludes to, but nothing suggested there worked for me.

I'm running Stata remotely from a server, if that could affect anything.

Answer