%SYSEVALF=%EVAL
实际时间 2.67 秒
CPU 时间 2.67 秒作者: shiyiming 时间: 2011-3-4 02:22 标题: Re: 请教问题,data步数学表达式字符解析? to superkuhasu
depends on how complex your opertors are, the solution could be complex or simple
is there any formula looks like "5*exp(1.7-2) / log(45)"?
I can only think of parsing the string at this moment作者: shiyiming 时间: 2011-3-4 11:52 标题: Re: 请教问题,data步数学表达式字符解析? to oloolo
toby dunn on SAS-L mentioned using RESOLVE function, which can handle standard math operators作者: shiyiming 时间: 2011-3-4 16:24 标题: Re: 请教问题,data步数学表达式字符解析? %eval和%SysEvalF快,但是复杂的表达情况好像不行吧~
resolve是可以处理,但是%eval需要3秒多的它用一分十几秒。作者: shiyiming 时间: 2011-3-5 17:30 标题: Re: 请教问题,data步数学表达式字符解析? %eval和%SysEvalF在解析的时候有问题。
如果有这样的函数就好了
data _null_;
a="52";
b="+23*log(4)";
c=TheFunction(a,b);
put c=;
run;
/*log:
c=83.884770306
*/作者: shiyiming 时间: 2011-3-5 17:46 标题: Re: 请教问题,data步数学表达式字符解析? 折腾了半天,还是得用原来的方法~~~作者: shiyiming 时间: 2011-3-5 18:36 标题: Re: 请教问题,data步数学表达式字符解析? [quote="qkaiwei":3po4zwy3]这个方法要改我公式,我不是特别喜欢. 仅做参考.
data tmp;
input formula:$20. a b c d;
call symput('formula',formula);
call symput('a',a);
call symput('b',b);
call symput('c',c);
call symput('d',d);
call execute('%let result=%sysevalf(&formula)');
result =symget('result');
put result;
cards;
&a*&b 1 2 3 4
&b*&c 1 2 3 4
;
run;[/quote:3po4zwy3]