由买买提看人间百态

topics

全部话题 - 话题: printdsn
(共0页)
s*******2
发帖数: 499
1
来自主题: Statistics版 - 请教一道SAS maro的题
SAS advanced 50题有一道题是这样的。
The following SAS program is submitted:
%let a=cat;
%macro animal;
%let a=dog;
%mend;
%animal
%put a is &a;
Which one of the following is written to the SAS log?
Correct answer: d
a. a is
b. a is &a
c. a is cat
d. a is dog
这个题答案的讲解说用local macro variable.
但是sas online的学习资料给的讲解似乎相反(具体内如如下)。请指点迷津。多谢。
The %PUT statement within the macro definition will write the value of the
local variable dsn to the SAS log, whereas the %PUT statement that follows
the macro definition wil... 阅读全帖
b****u
发帖数: 67
2
来自主题: Statistics版 - sas macro 问题,
1. 请问b为啥不对呀 ?? 谢谢
%macro printdsn(dsn,vars);
%if &vars= %then %do;
proc print data=&dsn;
title "Full Listing of %upcase(&dsn) data set";
run;
%end;
%else %do;
proc print data=&dsn;
var &vars;
title "Listing of %upcase(&dsn) data set";
run;
%end;
%mend;
a. %printdsn(sasuser.courses, course_title days);
b. %printdsn(dsn=sasuser.courses, vars=course_title days)
c. %printdsn(sasuser.courses, course_title days)
d. %printdsn(sasuser.courses, cours... 阅读全帖
n****e
发帖数: 226
3
来自主题: Statistics版 - 请教一道SAS maro的题
第二个例子里 macro 内的dsn是local macro variable
只在 macro 内部有效
如果你再加两个 %put statement 来显示 local MV, global MV
你会发现 %put _local_ 给你的是:PRINTDSN DSN sasuser.register
%put _global_ 给你的是:GLOBAL DSN sasuser.courses
%macro printdsn;
%local dsn;
%let dsn=sasuser.register;
%put The value of DSN inside Printdsn is &dsn;
%put _local_;
%put _global_;
%mend;
d******9
发帖数: 404
4
来自主题: Statistics版 - sas macro 问题,
1.If you want to use keyword macro parameters, you need declare them in the
macro definition first.
However, the definition here:
%macro printdsn(dsn,vars);
is not correct, it define the positional parameters.
If you want to use b, then you should define macro like this:
%macro printdsn(dsn=,vars=);
2. data _null_;
set sasuser.courses;
call symput('class', course_title);
run;
variable class是local 还是global ne ?
it is global, because it is defined in open code.
(共0页)