楼主: lxfkxkr
1652 1

[数据管理求助] 怪事~~矩阵local variable下的invalid syntax [推广有奖]

  • 3关注
  • 28粉丝

沉默的羔羊

已卖:740份资源

教授

77%

还不是VIP/贵宾

-

威望
0
论坛币
48004 个
通用积分
3484.6168
学术水平
42 点
热心指数
46 点
信用等级
31 点
经验
55021 点
帖子
894
精华
0
在线时间
2079 小时
注册时间
2009-4-8
最后登录
2025-12-2

楼主
lxfkxkr 在职认证  发表于 2015-8-16 14:31:18 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
执行下面这段代码有问题么?为什么显示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 的列向
就不行了 为什么?
二维码

扫码加我 拉你入群

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

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

关键词:Variable invalid SYNTAX Valid Local invalid local

沙发
andruw 在职认证  发表于 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.
已有 1 人评分经验 论坛币 学术水平 热心指数 收起 理由
夏目贵志 + 10 + 10 + 2 + 2 热心帮助其他会员

总评分: 经验 + 10  论坛币 + 10  学术水平 + 2  热心指数 + 2   查看全部评分

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

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