2

这个 sysfunc 调用有什么问题?

%let mystring = hello world;

%let mycount =  %sysfunc(count(&mystring, 'hello')); 

%put &mycount;

输出

[PUT]  0
4

1 回答 1

3

因为您在数据步之外,所以不需要引号hello(引号是字符串的一部分,而不是其分隔符)。所以这应该工作:

%let mystring = hello world;
%let mycount =  %sysfunc(count(&mystring, hello)); 
%put &mycount;

再举一个例子来说明这里发生了什么,这也将打印 1:

%let mystring = 'hello' world;
%let mycount =  %sysfunc(count(&mystring, 'hello')); 
%put &mycount;
于 2013-01-29T06:57:48.827 回答