0

Say I have a vector x, and a (short) list of values v to match against. I want to find which elements of x are present in v. For example, if

x = {10 11 12 13 12 13 14 15};
v = {12 13};

I want to obtain the vector {3 4 5 6}, these being the elements of x whose values are either 12 or 13. Is there a simple way to do this, without having to do an explicit loop over all the elements of v?

1 Answer 1

0

I assume you are in PROC IML. Use the XSECT function to find the intersection of the two sets:

z = xsect(x,v);

(and if you want the difference, use SETDIF).

BTW, there is a discussion forum dedicated to soley SAS/IML questions: http://support.sas.com/forums/forum.jspa?forumID=47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.