楼主: hookzhang
2628 3

[求助]有关Macro的一个问题 [推广有奖]

  • 0关注
  • 1粉丝

已卖:7690份资源

大专生

26%

还不是VIP/贵宾

-

威望
0
论坛币
4368 个
通用积分
0.1200
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
558 点
帖子
61
精华
0
在线时间
4 小时
注册时间
2006-12-19
最后登录
2016-4-16

楼主
hookzhang 发表于 2007-1-29 17:16:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币

%let new=inventry;
%macro name1;
%let new=report;
%mend name1;
%name1
这个时候new=report!!!!

我理解的是第一个语句在Global Symbol中产生有一个new

再定义Macro name1的时候在Local Symbol中又产生一个new。

但是程序执行的结果是改变Global Symbol中的new='report',而在Local Symbol中不生成新的宏变量

高手解释一下。可能是我理解宏的运行过程不够准确!

二维码

扫码加我 拉你入群

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

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

关键词:Macro acr CRO Mac symbol 求助 Macro

回帖推荐

nktiger1 发表于3楼  查看完整内容

Answer: When assign a value to macro variable, e.g "new", the steps are blow: 1. search the "new" in local symbol table. If exist, assign it. 2. if local symbol table has no "new", search the "new" in global symbol table. If exist, assign it. 3. if global symbol table has no "new", create local macro variable "new" and assign it. So, please try the code below, which should be what you wan ...

sakunamary 发表于2楼  查看完整内容

第一步:sas在内存生成一个内存段叫new的; 第二步:定义local var new,因为原来内存里有一个叫new的内存段,所以sas不会重新开辟一个内存储存local 的new,而是直接把local所定义的值覆盖掉原来的值。 第三步:global的值被改变了!!! 这个程序就告诉我们一个道理,sas的内存定义有点怪,变量(包括所有种类的变量)要小心命名。

本帖被以下文库推荐

沙发
sakunamary 发表于 2007-1-29 22:33:00

第一步:sas在内存生成一个内存段叫new的;

第二步:定义local var new,因为原来内存里有一个叫new的内存段,所以sas不会重新开辟一个内存储存local 的new,而是直接把local所定义的值覆盖掉原来的值。

第三步:global的值被改变了!!!

这个程序就告诉我们一个道理,sas的内存定义有点怪,变量(包括所有种类的变量)要小心命名。

已有 1 人评分论坛币 收起 理由
bakoll + 10 精彩帖子

总评分: 论坛币 + 10   查看全部评分

我sas故我在

藤椅
nktiger1 发表于 2007-3-8 10:38:00
Answer:
When assign a value to macro variable, e.g "new", the steps are blow:
1. search the "new" in local symbol table. If exist, assign it.
2. if local symbol table has no "new", search the "new" in global symbol table.
If exist, assign it.
3. if global symbol table has no "new", create local macro variable "new" and assign it.

So, please try the code below, which should be what you want:
%let new=inventry;
%macro name1;
%local new;
%let new=report;
%mend name1;
%name1
已有 1 人评分经验 论坛币 收起 理由
bakoll + 5 + 10 热心帮助其他会员

总评分: 经验 + 5  论坛币 + 10   查看全部评分

板凳
chenxueping 发表于 2007-3-11 16:25:00
有道理!

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-25 04:43