I am getting the following error in Stata while using a do file with a local macro:

clear 
capture log close

sysuse auto,clear 
log using stata,text replace

local varlist  price mpg rep78 weight length
reg 'varlist'
local close

Output

local varlist  price mpg rep78 weight length

reg 'varlist'
invalid name

I know that this is a very trivial issue, but I am not sure where this error is coming from.

Note that I didn't get error when I used global macro.

有帮助吗?

解决方案

To deregister a local macro the left quote should be a backtick. Try the following.

regress `varlist'

The backtick is on the same key as the tilde (i.e., ~) on most keyboards.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top