全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1289 2
2013-11-13
In function is in SAS macro language since SAS 9.2 was launched.

options minoperator nomlogic;
%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(7)

But one has to specify minoperator in option and mindelimiter=',' in a macro and it is hard to remember.

Now one can use data step 'in' function to have the same function and easy to remember.

%macro test2(value);

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

%mend;

%test2(3)
%test2(7)

二维码

扫码加我 拉你入群

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

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

全部回复
2013-11-13 15:47:51
我觉得在需要in计算时options minoperato,计算一完成马上关掉options nominoperato,这样才不会影响其他地方出现的In和#
二维码

扫码加我 拉你入群

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

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

2013-11-13 16:58:08
I used to think function IN are limited in data step.
And I think : %if %sysfunc(indexw("1 2 3 4 5 6","&value")) is also usefully.
But we don't have %indexw to use...
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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