%macro String(Str=);
%Let i=1;
%do %until(%sysevalf(%Scan(&Str,&i," ")= ));
%let Str&i=%Scan(&Str,&i," ");
%put ***Str&i=&&Str&i;
%let i=%eval(&i+1);
%end;
%mend String;
%String(Str=a b cd);
輸出結果 :
***Str1=a
***Str2=b
***Str3=cd
如果是%String(Str=a b c*d); 则报错如下:
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric
operand is required. The condition was: c*d=
ERROR: %EVAL function has no expression to evaluate, or %IF statement has no condition.
ERROR: The condition in the %DO %UNTIL loop, %sysevalf(%Scan(&Str,&i," ")= ), yielded an invalid
or missing value, . The macro will stop executing.
ERROR: The macro STRING will stop executing.
请问应该如果让它识别c*d是字符,并且进行正确判断呢? 谢谢。