楼主: 福建的小苗
2243 2

[编程问题求助] local 暂元在子do文件中无法显示 [推广有奖]

  • 30关注
  • 0粉丝

博士生

46%

还不是VIP/贵宾

-

威望
0
论坛币
809 个
通用积分
33.7755
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
7163 点
帖子
38
精华
0
在线时间
562 小时
注册时间
2013-9-21
最后登录
2025-3-2

楼主
福建的小苗 发表于 2015-10-21 20:44:20 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
两个命令:
一:
foreach num of numlist 0/1 {
foreach i of numlist 1/2{

*
dis _n in g "monthly200`num'0`i'" in y  "的初始缺失值数量是:" in y  `xx'
*
}
}

*
二:
foreach num of numlist 0/0 {
foreach i of numlist 1/12 {
if `i'<=2 {
local x=
do "C:\Users\miao\Desktop\others\1234.do"
   }
}
}


1234.do 内容是dis _n in g "monthly200`num'0`i'" in y  "的初始缺失值数量是:" in y  `xx'
两段命令差别在于 一个有子do文件,一个不包含子do文件。
问题是:为什么子do文件不能显示`num'和`i'暂元,是否子do文件不能使用上一级do文件的local暂元,如果是,怎么解决在子do中显示上一级的暂元?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Local do文件 OCA foreach Monthly local

回帖推荐

夏目贵志 发表于2楼  查看完整内容

从local macro这个名字就能看出来吧。这些macro只在一定的范围里有效。如果你想要在更大的范围使用,可以使用global macro;也可以把子do-file的内容写成程序,然后把需要的参数传递给这个程序。local macro适用的具体范围请看一下帮助文件。 Local macros exist solely within the program or do-file in which they are defined. If that program or do-file calls another program or do-file, the local macros previously ...

沙发
夏目贵志 发表于 2015-10-22 00:31:18
从local macro这个名字就能看出来吧。这些macro只在一定的范围里有效。如果你想要在更大的范围使用,可以使用global macro;也可以把子do-file的内容写成程序,然后把需要的参数传递给这个程序。local macro适用的具体范围请看一下帮助文件。
Local macros exist solely within the program or do-file in
which they are defined. If that program or do-file calls another program or do-file, the local macros
previously defined temporarily cease to exist, and their existence is reestablished when the calling
program regains control. When a program or do-file ends, its local macros are permanently deleted.
已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
福建的小苗 + 3 + 1 + 1 + 1 分析的有道理

总评分: 论坛币 + 3  学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

藤椅
lxswu 发表于 2018-3-13 23:36:33
夏目贵志 发表于 2015-10-22 00:31
从local macro这个名字就能看出来吧。这些macro只在一定的范围里有效。如果你想要在更大的范围使用,可以使 ...
您好!看您对stata中暂元的回答比较专业,我想向您请教一个问题:就是两个暂元能相加吗?有没有命令能让两个暂元加总?或者更具体到我这个例子,就是有个两层的嵌套循环,外层i=1/10,内层j=1/3,每次内层运算都要est sto 一下,如果单用i或者j作为est sto的名称,肯定是不够的,想请问一下您能否用i和j联合起来为其命名?如果不可以的话,有没有什么其他的命名方式?谢谢您!

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-31 23:22