楼主: bobguy
3922 4

Macro IN Operator in SAS v9.2 [推广有奖]

学科带头人

7%

还不是VIP/贵宾

-

威望
0
论坛币
14187 个
通用积分
28.9279
学术水平
344 点
热心指数
363 点
信用等级
228 点
经验
104882 点
帖子
1846
精华
0
在线时间
1608 小时
注册时间
2008-7-18
最后登录
2019-3-8

中级热心勋章

楼主
bobguy 发表于 2010-1-18 07:46:48 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
SAS v9.2 introduces macro option mindelimiter. This option simplifies the IN operation in a macro environment. Here is an example to illustrate the usage of the option.

options minoperator;
%macro test(value)/mindelimiter=',';

%if &value in 1,2,3,4,5,6 %then  %put Value found within list.;
%else                                          %put Value not in list.;

%mend;

%test(3)
%test(8)

*******************************;
30   options minoperator;
31   %macro test(value)/mindelimiter=',';
32
33   %if &value in 1,2,3,4,5,6 %then  %put Value found within list.;
34   %else                                          %put Value not in list.;
35
36   %mend;
37
38   %test(3)
Value found within list.
39   %test(8)
Value not in list.
二维码

扫码加我 拉你入群

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

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

关键词:operator Perato Macro Opera ERAT SAS Macro operator

沙发
jackbt123 发表于 2010-3-21 00:18:40
Hello bobguy,
How does IN operator work in Macro for 9.1.3 SP4? Is your example compatibility for 9.1.3 SP4?
For 9.1.3 SP4 in a Macro program, how can I test if a numeric variable's value falls into a list of number?
For instance, the list of number is 1,3,7,11,15,24,18,19,36,77,102,13,53
I means it is a long list.....

藤椅
soporaeternus 发表于 2010-3-21 22:18:22
一个scan循环每步匹配下,如果这个list本身是一个宏变量的话......
我不清楚9.2macro里in的运算机制是什么,但是这样的算法应该不会慢太多

有种习惯,总是觉得in很慢很慢......
Let them be hard, but never unjust

板凳
bobguy 发表于 2010-3-21 23:00:55
jackbt123 发表于 2010-3-21 00:18
Hello bobguy,
How does IN operator work in Macro for 9.1.3 SP4? Is your example compatibility for 9.1.3 SP4?
For 9.1.3 SP4 in a Macro program, how can I test if a numeric variable's value falls into a list of number?
For instance, the list of number is 1,3,7,11,15,24,18,19,36,77,102,13,53
I means it is a long list.....
I believe it only works in V9.2. BTY, It is a macro, you COULD write your version of in operator works in any SAS version.

报纸
jackbt123 发表于 2010-3-22 03:21:18
Thank you all for the valuable feedback....

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

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