楼主: yanglimachao
1329 2

[原创博文] 请高手帮忙分析一段程序 [推广有奖]

  • 0关注
  • 0粉丝

大专生

10%

还不是VIP/贵宾

-

威望
0
论坛币
5 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
713 点
帖子
42
精华
0
在线时间
46 小时
注册时间
2010-5-9
最后登录
2013-2-1

楼主
yanglimachao 发表于 2012-5-6 15:04:13 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
程序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的作用体现在哪里?
二维码

扫码加我 拉你入群

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

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

关键词:Quote let Mac put 程序

沙发
chendonghui1987 发表于 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

藤椅
yongjiang2 发表于 2012-7-4 21:35:11
学习

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-2 04:35