Date: Thu, 16 Sep 1999 19:30:15 -0500 shiling@math.wayne.edu "SAS(r) Discussion" Shiling Zhang Wayne State University Re: SAS/IML: "Select If" Function??? To: max_reid@MY-DEJA.COM text/plain; charset=us-ascii

Max,

The loc function does that. The loc function gives you the index which satisfy the condition. I guess your selif is equivelent to c=a(loc(a>0)).

Hope it helps.

proc iml; do i = 1 to 9; x=rannor(123); a=a//x; end; b=loc(a>0)`; c=a(|b|); print a b c; quit; run;

A B C -0.326593 2 1.5424369 1.5424369 3 0.2590291 0.2590291 5 0.7787204 -0.555834 9 0.7242336 0.7787204 -0.655197 -0.022105 -0.772647 0.7242336

max_reid@MY-DEJA.COM wrote:

> Does SAS/IML have an equivalent of Gauss's SELIF function? > > The SELIF function in Gauss defines a submatrix from an input matrix > according to some Boolean expression. Such an extraction could be > accomplished via a loop, but I am looking for a "vectorized" function. > > Thanks, > > Max > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't.

Back to: Top of message | Previous page | Main SAS-L page