<?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: How to find set of values  within a row using arrays? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-find-set-of-values-within-a-row-using-arrays/m-p/835062#M35929</link>
    <description>&lt;P&gt;Remove the ELSE.&lt;/P&gt;
&lt;P&gt;Initialize the condition to FALSE and in the DO loop set it TRUE when the condition is met.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set dsn;
  array num COL1-COL8;
  t='Invalid';
  do index= 1 to dim(num) while (t='Invalid');
    if num[index] in ('A','B','C') then t='Valid';
  end;
  drop index;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The meaning of the code is even clearer if you create a BOOLEAN numeric variable instead of a character variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set dsn;
  array num COL1-COL8;
  do index= 1 to dim(num) until (VALID);
    VALID = ( num[index] in ('A','B','C')  );
  end;
  drop index;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 25 Sep 2022 15:59:55 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-09-25T15:59:55Z</dc:date>
    <item>
      <title>How to find set of values  within a row using arrays?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-find-set-of-values-within-a-row-using-arrays/m-p/835059#M35928</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have below dataset&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;subjid&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;col1&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;col2&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;col3&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;col4&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;col5&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;col6&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;col7&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;col8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;A&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;A&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;B&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;B&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;B&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;B&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;C&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;2&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;A&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;A&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;B&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;B&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;C&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;A&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;B&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;3&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;A&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;B&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;A&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;B&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;B&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;A&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;C&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;C&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="30px"&gt;4&lt;/TD&gt;
&lt;TD height="30px"&gt;G&lt;/TD&gt;
&lt;TD height="30px"&gt;D&lt;/TD&gt;
&lt;TD height="30px"&gt;F&lt;/TD&gt;
&lt;TD height="30px"&gt;F&lt;/TD&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;K&lt;/TD&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to populate for subjects if any of the values from col1-col8 are "A" or "B" or "C" as valid ,if not as invalid&lt;/P&gt;
&lt;P&gt;In the above dataset, subjects ,1,2 &amp;amp; 3 are valid and 4 is invalid&amp;nbsp; as per the above condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried the below code , but it's not giving desired result&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;set dsn;&lt;BR /&gt;array num(*) $ COL1_COL8;&lt;BR /&gt;do i= 1 to dim(ses);&lt;BR /&gt;if num(i) in ("A","B","C") then t="Valid";&lt;BR /&gt;else t="Invalid";&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appreciate your response!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Sun, 25 Sep 2022 15:14:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-find-set-of-values-within-a-row-using-arrays/m-p/835059#M35928</guid>
      <dc:creator>sri1</dc:creator>
      <dc:date>2022-09-25T15:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to find set of values  within a row using arrays?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-find-set-of-values-within-a-row-using-arrays/m-p/835062#M35929</link>
      <description>&lt;P&gt;Remove the ELSE.&lt;/P&gt;
&lt;P&gt;Initialize the condition to FALSE and in the DO loop set it TRUE when the condition is met.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set dsn;
  array num COL1-COL8;
  t='Invalid';
  do index= 1 to dim(num) while (t='Invalid');
    if num[index] in ('A','B','C') then t='Valid';
  end;
  drop index;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The meaning of the code is even clearer if you create a BOOLEAN numeric variable instead of a character variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set dsn;
  array num COL1-COL8;
  do index= 1 to dim(num) until (VALID);
    VALID = ( num[index] in ('A','B','C')  );
  end;
  drop index;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Sep 2022 15:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-find-set-of-values-within-a-row-using-arrays/m-p/835062#M35929</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-25T15:59:55Z</dc:date>
    </item>
  </channel>
</rss>

