楼主: 小鳄鱼a
2459 10

请问个问题 [推广有奖]

11
Kitty喵喵喵 发表于 2016-11-22 17:23:09
写了一小段宏,学习中不断提高啦啦啦~
%macro replace(str =  ,find = , replace = );
data _null_;
        string = "&str";
        if find(string,"&find") then do;
                str1 = substr(string,1,index(string,"&find")-1);
                str2 = substr(string,length(str1)+length("&find")+1);
                out = strip(str1)||strip("&replace")||strip(str2);
        end;
        else do;
                out = "Not find '&find'";
        end;
        put out;
run;
%mend replace;

%replace(str = %str(SayHellotoWorld), find = %str(Hello), replace = %str(Yes));
%replace(str = %str(Say Hello to World), find = %str(Hi), replace = %str(Yes));
希望大神们还能提些建议让宏的适用性更广泛,谢谢~
结果.JPG
已有 1 人评分经验 收起 理由
prince315 + 20 热心帮助其他会员

总评分: 经验 + 20   查看全部评分

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

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