全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1282 2
2012-05-06
程序1:
%let a=mac;
%let b=%nrquote(&a);
%put &b;
输出:mac

程序2:
%let a=mac;
%let b=&a;
%put &b;
输出:mac

程序3:
%let a=mac;
%let b=%nrstr(&a);
%put &b;
输出:&a
后两个很明显,为什么程序1会输出mac呢?%nrquote的作用体现在哪里?
二维码

扫码加我 拉你入群

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

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

全部回复
2012-5-6 18:26:12
给你sas的解释你可以看一下。
Example 1: Quoting a Value that Might Contain a Mnemonic Operator
The macro DEPT1 receives abbreviations for states and therefore might receive the value OR for Oregon.
%macro dept1(state);
      /* without %quote -- problems might occur */
   %if &state=nc %then
       %put North Carolina Department of Revenue;
   %else %put Department of Revenue;
%mend dept1;

%dept1(or)
When the macro DEPT1 executes, the %IF condition executes a %EVAL function, which evaluates or as a logical operator in this expression. Then the macro processor produces an error message for an invalid operand in the expression or=nc .
The macro DEPT2 uses the %QUOTE function to treat characters that result from resolving &STATE as text:
%macro dept2(state);
      /* with %quote function--problems are prevented */
   %if %quote(&state)=nc %then
       %put North Carolina Department of Revenue;
   %else %put Department of Revenue;
%mend dept2;

%dept2(or)
The %IF condition now compares the strings or and nc and writes to the SAS log:
Department of Revenue
二维码

扫码加我 拉你入群

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

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

2012-7-4 21:35:11
学习
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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