全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
1679 1
2015-08-16
执行下面这段代码有问题么?为什么显示invalid syntax
执行下面代码没有任何问题

mat a = J(4,4,1) + I(4)
  mat a[3,2] = 9
    local c = colsof(a)      // 返回矩阵 a 的列数
        mat ss = J(`c',1,1)   // 定义一个 cx1 的列向



但是分别执行就出现invalid syntax
先执行
mat a = J(4,4,1) + I(4)
  mat a[3,2] = 9
    local c = colsof(a)      // 返回矩阵 a 的列数

再执行
        mat ss = J(`c',1,1)   // 定义一个 cx1 的列向
就不行了 为什么?
二维码

扫码加我 拉你入群

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

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

全部回复
2015-8-16 15:41:14
若分开执行,需换成global。手册有详细说明:

Macros come in two types, global and local. Macro names are up to 32 characters long for global
macros and up to 31 characters long for local macros. The contents of global macros are defined with
the global command and those of local macros with the local command. Global macros, once
defined, are available anywhere in Stata. 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.
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群