如何转义stata 中的括号 - 无效 '(' 错误 r(196)

问题描述

我必须复制使用宏作为文件名的同事的 do 文件。问题是路径名包含括号,导致问题:

*setting directory
cd "D:/Dropbox (Center for Child Well-being and Development)/2020/Playground"

*setup
sysuse auto
save "/Dropbox (Center for Child Well-being and Development)/example",replace


*problem
global path "/Dropbox (Center for Child Well-being and Development)"
local file "/example.dta"
global data "$path`file'""

disp "$data"
use $data

我得到以下输出

. disp "$data"
/Dropbox (Center for Child Well-being and Development)/example.dta

. use $data
invalid '(' 
r(198);

我知道将引号内的宏调用为 use "$data" 可以完成这项工作,但由于它不是我的 do 文件,我想尽量避免更改每次使用宏的地方。 我试图用 \( 转义括号,并在构建全局时在我能想象的任何位置添加各种数量的引号。我还尝试添加转义引号 \",但两者都不起作用。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...