写了一小段宏,学习中不断提高啦啦啦~
%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));
希望大神们还能提些建议让宏的适用性更广泛,谢谢~