sas-比较过程iml中没有循环的向量分量
我正在用proc iml编写一个代码,我想运行一个if语句,它计算向量的每个分量,并在一个步骤中返回另一个向量。是否有这样做的功能?代码如下:sas-比较过程iml中没有循环的向量分量,sas,sas-iml,Sas,Sas Iml,我正在用proc iml编写一个代码,我想运行一个if语句,它计算向量的每个分量,并在一个步骤中返回另一个向量。是否有这样做的功能?代码如下: proc iml; use chap0; read all var{X} into X; read all var{t} into t; count=0;/*init count number*/ W=1; s= exp(X*w)/(1+ exp(X*w)); s1=j(5,1,10); do step = 1 t
proc iml;
use chap0; read all var{X} into X;
read all var{t} into t;
count=0;/*init count number*/
W=1;
s= exp(X*w)/(1+ exp(X*w));
s1=j(5,1,10);
do step = 1 to 6;
count=count+1;
s= exp(X*w)/(1+ exp(X*w));
if s <0.5 then s1= 0; /**in this part I need to get a vector with 0 and 1**/
if s >0.5 then s1= 1; /*I need to evaluate each component of the vector in this step*/
print s s1;
e = ssq(s - t);
g=2*(s-t)*s`*(1-s);
h=2 * s * (1 - s)` * (s * (1 - s)` + (s - t) * (1 - 2 * s)`);
o=j(1,5,1);
gg=(o*g);
hh=((o*h)*o`);
gi=gg/hh;
w1=w-gi;
s= exp(X*w)/(1+ exp(X*w));
if s <0.5 then s1= 0; /**here again:
in this part I need to get a vector with 0 and 1**/
if s >0.5 then s1= 1;
print s1;
e = ssq(s - t);
e1 = ssq(s1 - t);
w=w1;
print w w1 e e1 count;
end;
proc-iml;
使用chap0;将所有变量{X}读入X;
将所有var{t}读入t;
计数=0/*初始计数*/
W=1;
s=exp(X*w)/(1+exp(X*w));
s1=j(5,1,10);
执行步骤=1至6;
计数=计数+1;
s=exp(X*w)/(1+exp(X*w));
如果s 0.5,则s1=1/*在这一步中,我需要计算向量的每个分量*/
打印s1;
e=ssq(s-t);
g=2*(s-t)*s`*(1-s);
h=2*s*(1-s)`*(s*(1-s)`+(s-t)*(1-2*s)`);
o=j(1,5,1);
gg=(o*g);
hh=((o*h)*o`);
gi=gg/hh;
w1=w-gi;
s=exp(X*w)/(1+exp(X*w));
如果s 0.5,则s1=1;
打印s1;
e=ssq(s-t);
e1=ssq(s1-t);
w=w1;
打印w w1 e e1计数;
结束;
谢谢 这就像看起来一样简单
proc iml;
s = 1:5;
s1 = (s>3); *this assigns 1 (true) or 0 (false), for each element, based on relation to 3.;
print s1;
quit;
因此,您需要一个向量
s1
,其元素数与s
相同,但1/0取决于if>或<0.5?