全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1163 2
2013-09-24
%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是字符,并且进行正确判断呢? 谢谢。



二维码

扫码加我 拉你入群

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

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

全部回复
2013-9-24 12:54:15
%do %until(%sysevalf(%quote(%Scan(&Str,&i," "))= ));
二维码

扫码加我 拉你入群

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

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

2013-9-24 13:27:04
pobel 发表于 2013-9-24 12:54
%do %until(%sysevalf(%quote(%Scan(&Str,&i," "))= ));
恩,可以啦,谢谢
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群