<?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 SAS/IML Where Clause with USE or READ Statement in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-Where-Clause-with-USE-or-READ-Statement/m-p/819808#M5832</link>
    <description>&lt;P&gt;I need to filter data in SAS/IML with a USE or READ statement by specifying rows where a variable DOES NOT start with certain characters.&amp;nbsp; SAS/IML supports a where clause with the =: operand, such as USE mydata where(myID =: "AB"); to select rows where the myID variable starts with AB.&amp;nbsp; In my application, I only know that I do not want rows that begin with AB, but SAS/IML does not seem to support a statement like:&amp;nbsp; USE mydata where(myID ^=: "AB");&lt;/P&gt;
&lt;P&gt;I know I can preprocess the data before calling IML, but I would like to find a way to filter the incoming data directly in IML.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jun 2022 19:52:43 GMT</pubDate>
    <dc:creator>JMPFan</dc:creator>
    <dc:date>2022-06-22T19:52:43Z</dc:date>
    <item>
      <title>SAS/IML Where Clause with USE or READ Statement</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-Where-Clause-with-USE-or-READ-Statement/m-p/819808#M5832</link>
      <description>&lt;P&gt;I need to filter data in SAS/IML with a USE or READ statement by specifying rows where a variable DOES NOT start with certain characters.&amp;nbsp; SAS/IML supports a where clause with the =: operand, such as USE mydata where(myID =: "AB"); to select rows where the myID variable starts with AB.&amp;nbsp; In my application, I only know that I do not want rows that begin with AB, but SAS/IML does not seem to support a statement like:&amp;nbsp; USE mydata where(myID ^=: "AB");&lt;/P&gt;
&lt;P&gt;I know I can preprocess the data before calling IML, but I would like to find a way to filter the incoming data directly in IML.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 19:52:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-Where-Clause-with-USE-or-READ-Statement/m-p/819808#M5832</guid>
      <dc:creator>JMPFan</dc:creator>
      <dc:date>2022-06-22T19:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: SAS/IML Where Clause with USE or READ Statement</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-Where-Clause-with-USE-or-READ-Statement/m-p/819810#M5833</link>
      <description>&lt;P&gt;Why not just use normal SAS dataset options like you would in PROC PRINT instead of trying to use ANY type of IML syntax.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=sashelp.class(where=(name ^=: 'A'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So in IML try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;USE mydata(where=(myID ^=: "AB"));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Jun 2022 19:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-Where-Clause-with-USE-or-READ-Statement/m-p/819810#M5833</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-22T19:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS/IML Where Clause with USE or READ Statement</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-Where-Clause-with-USE-or-READ-Statement/m-p/819933#M5834</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;I know I can preprocess the data before calling IML, but I would like to find a way to filter the incoming data directly in IML.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When programmers want to do "filter ...directly in IML," it is often because the value you are trying to filter is not known prior to running the IML program. Rather, it is produced during the program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you have discovered, the WHERE option on the USE statement in IML does not support the same options as the WHERE option for the DATA= option in Base SAS. I suggest you use the SUBMIT/ENDSUBMIT block to call the DATA step from within your IML program to mark or filter the data. If necessary, you can pass a parameter that indicates the value you are using to filter the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, the following program uses the SUBMIT/ENDSUBMIT block to exclude all students whose names begin with the previs "Al":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc iml;
Str = "Al";       /* string to search for */
Len = nleng(Str); /* length of string */

submit Str Len;   /* send parameters to Base SAS */
data _Filter / view=_Filter;  /* create data VIEW */
set sashelp.class; 
/* use subsetting IF stament to exclude certain obs */
if substr(Name, 1, &amp;amp;Len) ^= "&amp;amp;Str";
run;
endsubmit;

use _Filter; 
read all var "name";
close;

print name;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If, fo some reason, you don't want to use the subsetting IF statement to exclude the obs, you can create an indicator variable in the DATA step such as&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;_Include = (substr(Name, 1, &amp;amp;Len) ^= "&amp;amp;Str");
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then in your IML program use the syntax&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;use _Filter where(_Include=1); 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 10:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-Where-Clause-with-USE-or-READ-Statement/m-p/819933#M5834</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-06-23T10:24:44Z</dc:date>
    </item>
  </channel>
</rss>

