楼主: jackbt123
2248 2

[SAS Data Management] Getting the IN operator to FUNCTION [推广有奖]

  • 0关注
  • 0粉丝

硕士生

59%

还不是VIP/贵宾

-

威望
0
论坛币
110 个
通用积分
0.3000
学术水平
2 点
热心指数
4 点
信用等级
2 点
经验
847 点
帖子
56
精华
0
在线时间
263 小时
注册时间
2008-11-28
最后登录
2017-9-21

楼主
jackbt123 发表于 2010-3-22 03:57:37 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
Getting the IN operator to FUNCTION inside a SAS Macro

By: Perry Watts

Recommended Reading:
http://www.nesug.org/Proceedings/nesug09/cc/cc05.pdf
http://www.lexjansen.com/cgi-bin/xsl_transform.php?x=tmac&s=nesug_t&c=nesug

Related Link:
http://www.pinggu.org/bbs/thread-690356-1-1.html
By: bobguy



/* ---------------------------------------------------------------------------
Program : inFcn.sas
Author : Perry Watts
Date : 10Jun2009 14:39
Project : N09 Coder's Corner
Title : CC05: Getting the IN operator to FUNCTION inside a SAS® Macro
Path : Referenced in the SASAUTOS option in the CALLING program.
Purpose : Use inFcn to replicate the IN operator inside a macro.
Notes : Positional Keywords are being used to mimic operands assigned to
the IN operator.
------------------------------------------------------------------------ */
%macro InFcn (excerpt, matchlist);
%local TorF quotes;
%let quotes=%str(%'%");
%let excerpt = %nrbquote(%sysfunc(compress(&excerpt,""es")));
%let matchlist = %sysfunc(translate(&matchList,' ', ','));
%let matchlist = %nrbquote(%sysfunc(compress(&matchList,""es")));
%let TorF = %SYSFUNC(indexW(%upcase(&matchlist), %upcase(&excerpt)));
&TorF
%mend InFcn;
二维码

扫码加我 拉你入群

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

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

关键词:Management Managemen operator function getting SAS Management getting function operator

本帖被以下文库推荐

沙发
soporaeternus 发表于 2010-3-22 09:45:40
算法看懂了,有些写法没看懂,copy下来运行有错,高手入指教啊
Let them be hard, but never unjust

藤椅
jackbt123 发表于 2010-3-23 07:36:19
2# soporaeternus
Please try running following codes....

%macro InFcn (excerpt, matchlist);
%local TorF quotes;
%let quotes=%str(%'%");
%let excerpt = %nrbquote(%sysfunc(compress(&excerpt,"&quotes")));
%let matchlist = %sysfunc(translate(&matchList,' ', ','));
%let matchlist = %nrbquote(%sysfunc(compress(&matchList,"&quotes")));
%let TorF = %SYSFUNC(indexW(%upcase(&matchlist), %upcase(&excerpt)));
&TorF
%mend InFcn;

%macro enumerate;
data OneAlso;
length ingroup $
1;
%do i= 1 %to 10;
i=&i;
%if %infcn(&i, 1 4 5) %then %str(ingroup='Y';);
%else %str(ingroup='N';);
output;
%end;
run;
title1
'Data: OneAlso';
proc print data=OneAlso;
run;
%mend enumerate;
%enumerate

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

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