<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Proc IML: If value in vector /matrix in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417046#M3843</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
A={1 2 3 4 5 6 7 8 9 10};
B={11 12 13 14 15 16 17 43 33 3};
     if any(element(A,B)) then print "yes";
	  else print 'no';
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 29 Nov 2017 13:47:55 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-11-29T13:47:55Z</dc:date>
    <item>
      <title>Proc IML: If value in vector /matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/416743#M3838</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I'm trying to figure out a efficient way to see if a value, numerical or character, is in a vector.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The optimal way of doing it would be if A in B.. But i havent managed to get this to work, nor find any information about it under documentation.&lt;BR /&gt;&lt;BR /&gt;a simple solution to the problem is:&lt;BR /&gt;&lt;BR /&gt;A={1 2 3 4 5 6 7 8 9 10};&lt;BR /&gt;B={11 12 13 14 15 16 17 43 33 3};&lt;BR /&gt;do i=1 to ncol(B);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; if any(A=B[i]) then print "yes";&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;This is however quite messy. Is there an easy solution to my problem such as in datastep: where X in (' ', ' ')?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*EDIT* i may add that i have SAS/IML&amp;nbsp;9.21_M.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 16:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/416743#M3838</guid>
      <dc:creator>Shawnty</dc:creator>
      <dc:date>2017-11-28T16:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML: If value in vector /matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/416766#M3839</link>
      <description>&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif"&gt;&lt;FONT size="2"&gt;Have&lt;/FONT&gt;&lt;FONT size="2"&gt; a look at the set functions XSECT and &lt;/FONT&gt;&lt;FONT size="2"&gt;ELEMENT.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x = xsect(A, B);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif"&gt;&lt;FONT size="2"&gt;will&lt;/FONT&gt;&lt;FONT size="2"&gt; give a row vector with the values that are common to both A and &lt;/FONT&gt;&lt;FONT size="2"&gt;B.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;idx = loc(element(B, x));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif"&gt;&lt;FONT size="2"&gt;will&lt;/FONT&gt;&lt;FONT size="2"&gt; give a vector with the values of the loop variable i that correspond to a &lt;/FONT&gt;&lt;FONT size="2"&gt;"yes"&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT size="2"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 17:09:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/416766#M3839</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2017-11-28T17:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML: If value in vector /matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/416811#M3840</link>
      <description>&lt;P&gt;To add to what Ian said, see this recent question:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Equivalent-of-VLOOKUP-without-using-loops/m-p/416055#M3833" target="_self"&gt;https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Equivalent-of-VLOOKUP-without-using-loops/m-p/416055#M3833&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;and the blog post&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2015/05/11/loc-element-trick.html" target="_self"&gt;"Finding observations that satisfy multiple conditions: The LOC-ELEMENT technique"&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 19:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/416811#M3840</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-11-28T19:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML: If value in vector /matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417045#M3842</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
A={1 2 3 4 5 6 7 8 9 10};
B={11 12 13 14 15 16 17 43 33 3};
     if any(element(A,B)) then print "yes";
	  else print 'no';
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Nov 2017 13:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417045#M3842</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-29T13:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML: If value in vector /matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417046#M3843</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
A={1 2 3 4 5 6 7 8 9 10};
B={11 12 13 14 15 16 17 43 33 3};
     if any(element(A,B)) then print "yes";
	  else print 'no';
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Nov 2017 13:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417046#M3843</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-29T13:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML: If value in vector /matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417665#M3844</link>
      <description>&lt;P&gt;Hi, when i try to run the code u posted i get the following message. Is it due to me having an too old SAS client?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;124 proc iml;&lt;BR /&gt;NOTE: IML Ready&lt;BR /&gt;&lt;BR /&gt;141 A={1 2 3 4 5 6 7 8 9 10};&lt;BR /&gt;142 B={11 12 13 14 15 16 17 43 33 3};&lt;BR /&gt;143 if any(element(A,B)) then print "yes";&lt;BR /&gt;144 else print 'no';&lt;BR /&gt;ERROR: Invocation of unresolved module ELEMENT.&lt;/P&gt;&lt;P&gt;statement : IF at line 143 column 6&lt;BR /&gt;145 quit;&lt;BR /&gt;NOTE: Exiting IML.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE IML used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 07:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417665#M3844</guid>
      <dc:creator>Shawnty</dc:creator>
      <dc:date>2017-12-01T07:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML: If value in vector /matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417666#M3845</link>
      <description>Hi Rick_SAS, Please see my response to Ksharp, seeing your solution uses the element function.</description>
      <pubDate>Fri, 01 Dec 2017 07:54:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417666#M3845</guid>
      <dc:creator>Shawnty</dc:creator>
      <dc:date>2017-12-01T07:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML: If value in vector /matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417722#M3846</link>
      <description>&lt;P&gt;The ELEMENT function was introduced in SAS 9.3, which was shipped in 2011. There have been seven releases of SAS since then. The most current release is the SAS 9.4M5. The "M5" means it is the fifth release of SAS 9.4.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 11:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417722#M3846</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-12-01T11:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML: If value in vector /matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417727#M3847</link>
      <description>I suspected that. Do you know of an alternative solution for SAS/IML 9.21_M?</description>
      <pubDate>Fri, 01 Dec 2017 11:40:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417727#M3847</guid>
      <dc:creator>Shawnty</dc:creator>
      <dc:date>2017-12-01T11:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML: If value in vector /matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417742#M3848</link>
      <description>&lt;P&gt;I looked through my archives and found this&amp;nbsp;SAS/IML module that emulates the ELEMENT function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;

start ElementFunc(x, y);
   if ncol(x)=0 then return(_NULL_);
   b = j(nrow(x), ncol(x), 0);
   if ncol(y)=0 then return(b);
   
   u = xsect(x, y);
   if ncol(u)=0 then return(b);
   
   do i = 1 to ncol(u);
      b = bor(b, (x=u[i]));
   end;
   return (b);
finish;

x = {0, 0.5, 1, 1.5, 2, 2.5, 3, 0.5, 1.5, 3, 3, 1};
set = {0, 1, 3};
check = {1,0,1,0,0,0,1,0,0,1,1,1};  /* the correct result */
a = ElementFunc(x, set);  /* compare with  b = element(x, set); */
print set, x a check;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Dec 2017 13:00:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417742#M3848</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-12-01T13:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML: If value in vector /matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417743#M3849</link>
      <description>Thank you very much!</description>
      <pubDate>Fri, 01 Dec 2017 13:01:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417743#M3849</guid>
      <dc:creator>Shawnty</dc:creator>
      <dc:date>2017-12-01T13:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML: If value in vector /matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417744#M3850</link>
      <description>&lt;P&gt;How about this one ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
A={1 2 3 4 5 6 7 8 9 10};
B={11 12 13 14 15 16 17 43 33 3};
if ncol(xsect(A,B))=0 then print 'No' ; 
 else print 'Yes';
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Dec 2017 13:02:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-If-value-in-vector-matrix/m-p/417744#M3850</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-12-01T13:02:46Z</dc:date>
    </item>
  </channel>
</rss>

