今天编程中用到了一个计算式
Y=(X)**(1/3)
也就是Y是X的1/3次方。
奇怪的是,当X为负数时,SAS无法计算。
比如X为-0.027,那么Y应该为-0.3,可是SAS不能计算。
我用的是SAS 9.3
有意思的是,我的三星手机自带的计算器也有同样的问题。倒是google可以计算这个。
各位是否可以试试?难道我的SAS有问题?怎么解决呢?
急用,在线等。多谢!
楼主: leonxf
|
2423
2
不可思议,SAS居然不能算这个?在线等 |
大专生 65%
-
|
回帖推荐This is not surprising, because SAS calculate the answer with the LOG as below. So LOG of a negative value is not accepted... You have to
handle this yourself!
x ** y = exp(log(x)*y);
To bypass this problem, you need to write a macro in SAS. The macro looks like below:
From http://support.sas.com/kb/24/618.html
%macro nroot(invar,outvar,root);
/* If the root is odd, ...
| ||
| ||||||||||
京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明 免责及隐私声明