由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SAS ADVANCED 一道题求助
相关主题
一道ADV 130 题目问一些sas的问题
请帮忙看3道SAS题。请教一道SAS maro的题
SAS call symput question一个关于macro的问题,多谢。
请教SAS adv 题库一道macro题请教一个macro的问题
请问SAS advanced macro global 和locala question about SAS
SAS Macro 问题请教 。。。问个SAS题目,
求助,SAS ADV 130 中94SAS help
SAS初级问题请教请问SAS ADV 130中74 和80题
相关话题的讨论汇总
话题: macro话题: proc话题: symput话题: variable话题: sas
进入Statistics版参与讨论
1 (共1页)
r******m
发帖数: 369
1
At the start of a new SAS session, the following program is submitted:
%macro one;
data _null_;
call symput('proc','means');
run;
%mend;
%one()
What is the result?
A. The macro variable PROC is stored in the local symbol table.
B. The macro variable PROC is stored in the global symbol table.
C. The macro variable PROC is stored in the sas catalog work.sasmacr.
D. The program fails to execute because PROC is a reserved word.
答案选B,怎么会呢?应该是A吧,可是我试了一下code真的是B啊,为什么啊?
l*********s
发帖数: 5409
2
why it shall be A? SAS is not C
r******m
发帖数: 369
3
查了manual,这道题得情况属于a data step that contains a symput把?
You can create local macro variables with parameters in a macro definition
a %LET statement within a macro definition
a DATA step that contains a SYMPUT routine within a macro definition
a SELECT statement that contains an INTO clause in PROC SQL within a macro
definition
a %LOCAL statement.
r******m
发帖数: 369
4
汗,同学,我当然知道SAS不是C(看了半天才理解你说啥),你这个回答不能解决我的
问题啊。

【在 l*********s 的大作中提到】
: why it shall be A? SAS is not C
b**********i
发帖数: 1059
5
CALL SYMPUT may not create a GLOBAL macro variable when defined inside a
macro definition. When we use
CALL SYMPUT inside a macro definition, it will write the macro variable
values into a local symbol table, if the
macro has a non empty local symbol table. If macro has an empty local symbol
table, the macro variable defined
inside a macro, using CALL SYMPUT routine has global scope. The rules do not
apply when you explicitly define
them as GLOBAL or LOCAL.

【在 r******m 的大作中提到】
: 汗,同学,我当然知道SAS不是C(看了半天才理解你说啥),你这个回答不能解决我的
: 问题啊。

l*********s
发帖数: 5409
6
Every language has its own syntax and rules you must remember. That is it.

【在 r******m 的大作中提到】
: 汗,同学,我当然知道SAS不是C(看了半天才理解你说啥),你这个回答不能解决我的
: 问题啊。

d******9
发帖数: 404
7
B. The macro variable PROC is stored in the global symbol table.
It is correct.
When we use CALL SYMPUT to create a macro variable, please be noted it is
assigned to the MOST LOCAL, NON-EMPTY symbol table.
In this case, the macro ONE is empty, the created macro variable can not be
assigned to it, and then it goes to Global, instead.
r******m
发帖数: 369
8
baicai和dido都是对的
假如我把codes改成
%macro one;
%let guess=random;
data _null_;
call symput('proc','means');
run;
%mend;
%one
这里的proc就是local macro variable了。
r******m
发帖数: 369
9
我不想跟您绕了,我就是上来问一个SAS的问题的,您跟我一会儿扯C一会儿扯别的干吗
啊。虽然多谢你给我顶贴,但是不得不说,您的回帖没啥营养。

【在 l*********s 的大作中提到】
: Every language has its own syntax and rules you must remember. That is it.
r******m
发帖数: 369
10
楼上两位接收包子,谢谢!
相关主题
SAS Macro 问题请教 。。。问一些sas的问题
求助,SAS ADV 130 中94请教一道SAS maro的题
SAS初级问题请教一个关于macro的问题,多谢。
进入Statistics版参与讨论
l*********s
发帖数: 5409
11
sorry, I had thought if macro variables not declared by %local will always
be treated as global. Good lesson to learn.

【在 r******m 的大作中提到】
: 我不想跟您绕了,我就是上来问一个SAS的问题的,您跟我一会儿扯C一会儿扯别的干吗
: 啊。虽然多谢你给我顶贴,但是不得不说,您的回帖没啥营养。

l***a
发帖数: 12410
12
其实可能只要在macro里面,都用%local/%global定义macro var是个好习惯

always

【在 l*********s 的大作中提到】
: sorry, I had thought if macro variables not declared by %local will always
: be treated as global. Good lesson to learn.

h******e
发帖数: 1791
13
在一个macro里,如果call symput前面没有定义其他macro variable(包括macro的参
数),call symput定义的macro variable就是global的。这就是为什么call symputx
在某些条件下更好使的原因。

【在 r******m 的大作中提到】
: At the start of a new SAS session, the following program is submitted:
: %macro one;
: data _null_;
: call symput('proc','means');
: run;
: %mend;
: %one()
: What is the result?
: A. The macro variable PROC is stored in the local symbol table.
: B. The macro variable PROC is stored in the global symbol table.

s******r
发帖数: 1524
14
I can not remember clearly. It looks if you create some local macro
variables or dataset, then symput would create local macro variables.
Otherwise it should be global.

【在 r******m 的大作中提到】
: baicai和dido都是对的
: 假如我把codes改成
: %macro one;
: %let guess=random;
: data _null_;
: call symput('proc','means');
: run;
: %mend;
: %one
: 这里的proc就是local macro variable了。

b**********i
发帖数: 1059
15
hehe

【在 r******m 的大作中提到】
: 楼上两位接收包子,谢谢!
1 (共1页)
进入Statistics版参与讨论
相关主题
请问SAS ADV 130中74 和80题请问SAS advanced macro global 和local
在线等:急问大牛帮我看看SAS macro里的问题SAS Macro 问题请教 。。。
SAS里用macro的文件名里数字的问题求助,SAS ADV 130 中94
How to the macro regression with if?SAS初级问题请教
一道ADV 130 题目问一些sas的问题
请帮忙看3道SAS题。请教一道SAS maro的题
SAS call symput question一个关于macro的问题,多谢。
请教SAS adv 题库一道macro题请教一个macro的问题
相关话题的讨论汇总
话题: macro话题: proc话题: symput话题: variable话题: sas