<?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: Can I use Like and In function in a where statement together? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876268#M38880</link>
    <description>&lt;P&gt;I'm going to go out on a limb and suggest that you may be wanting an OR instead of AND&lt;/P&gt;
&lt;P&gt;In this code (removing&amp;nbsp; problem second WHERE) if your T1_client_code is "like" 'Hoist%' then it will &lt;STRONG&gt;never&amp;nbsp;&lt;/STRONG&gt;be one of the members in that list of values. The like is going to find values that start with HOIST and none of the values in the list do so you won't ever get any result.&lt;/P&gt;
&lt;PRE&gt;	where t1.client_code like ('HOIST%')
&lt;FONT size="5" color="#FF00FF"&gt;&lt;STRONG&gt;and&lt;/STRONG&gt;&lt;/FONT&gt; t1.client_code in ('IDEM001','IDEM002','IDEM003','IDEM004','IDEM005','IDEM006','VANQUIS215','VANQUIS216','VANQUIS217','VANQUIS218','VANQUIS219')

&lt;/PRE&gt;
&lt;P&gt;If you have a second variable that has the values in the list, then the above would make sense but not for a single variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: End Proc SQL with a QUIT statement, not run. otherwise the procedure continues to run.&lt;/P&gt;</description>
    <pubDate>Wed, 17 May 2023 16:19:46 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-05-17T16:19:46Z</dc:date>
    <item>
      <title>Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876262#M38878</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am writing a code where I need to find Hoist001, Hoist002 and so on so I have used where client_code like (Hoist%) but I also want to include some other client code. I tried to include them by using where client_code in a,b,c etc but I am getting error. So I want to know is it possible to use where statement for like and other where statement using In?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Hoist_Accs_To_Track as 
	(select	t3.icustomerid,
			t1.debt_code,
			t1.client_code, 
			t1.Rep_code,
			t2.Accountstatus,
			t2.rep_descrn as Rep_Description, 
			t1.dt_curbal as Balance, 
			t1.dt_debtval as Orig_Balance,
			datepart(t1.dt_rep_init_date) as Rep_Entry_Date format date9.,
			datepart(t1.dt_datinstr) as Bookon_Date format date9.
			from p2scflow.debt as t1
				left join p2scflow.repcode as t2 on t1.rep_code = t2.rep_code
				left join p2scflow.debtcust as t3 on t1.debt_code = t3.debt_code
					where t1.client_code like ('HOIST%')
and where t1.client_code in ('IDEM001','IDEM002','IDEM003','IDEM004','IDEM005','IDEM006','VANQUIS215','VANQUIS216','VANQUIS217','VANQUIS218','VANQUIS219'));
run;

Error log:
29         proc sql;
30         create table Hoist_Accs_To_Track as
31         	(select	t3.icustomerid,
32         			t1.debt_code,
33         			t1.client_code,
34         			t1.Rep_code,
35         			t2.Accountstatus,
36         			t2.rep_descrn as Rep_Description,
37         			t1.dt_curbal as Balance,
38         			t1.dt_debtval as Orig_Balance,
39         			datepart(t1.dt_rep_init_date) as Rep_Entry_Date format date9.,
40         			datepart(t1.dt_datinstr) as Bookon_Date format date9.
41         			from p2scflow.debt as t1
42         				left join p2scflow.repcode as t2 on t1.rep_code = t2.rep_code
43         				left join p2scflow.debtcust as t3 on t1.debt_code = t3.debt_code
44         					where t1.client_code like ('HOIST%')
45         and where t1.client_code in
                     __
                     22
                     76
45       ! ('IDEM001','IDEM002','IDEM003','IDEM004','IDEM005','IDEM006','VANQUIS215','VANQUIS216','VANQUIS217','VANQUIS218','VANQUIS
45       ! 219'));
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, (, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN, 
              CONTAINS, EQ, EQT, GE, GET, GROUP, GT, GTT, HAVING, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.  

ERROR 76-322: Syntax error, statement will be ignored.

2                                                          The SAS System                              15:14 Wednesday, May 17, 2023

NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
46         run;
NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.
47         
48         %LET _CLIENTTASKLABEL=;
49         %LET _CLIENTPROCESSFLOWNAME=;
50         %LET _CLIENTPROJECTPATH=;
51         %LET _CLIENTPROJECTPATHHOST=;
52         %LET _CLIENTPROJECTNAME=;
53         %LET _SASPROGRAMFILE=;
54         %LET _SASPROGRAMFILEHOST=;
55         
56         ;*';*";*/;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 May 2023 15:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876262#M38878</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-05-17T15:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876265#M38879</link>
      <description>&lt;P&gt;I believe you don't need another "WHERE" after the AND boolean operator in -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*corrected*/
where t1.client_code like ('HOIST%')
and t1.client_code in ('IDEM001','IDEM002','IDEM003','IDEM004','IDEM005','IDEM006','VANQUIS215','VANQUIS216','VANQUIS217','VANQUIS218','VANQUIS219'));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 May 2023 16:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876265#M38879</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2023-05-17T16:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876268#M38880</link>
      <description>&lt;P&gt;I'm going to go out on a limb and suggest that you may be wanting an OR instead of AND&lt;/P&gt;
&lt;P&gt;In this code (removing&amp;nbsp; problem second WHERE) if your T1_client_code is "like" 'Hoist%' then it will &lt;STRONG&gt;never&amp;nbsp;&lt;/STRONG&gt;be one of the members in that list of values. The like is going to find values that start with HOIST and none of the values in the list do so you won't ever get any result.&lt;/P&gt;
&lt;PRE&gt;	where t1.client_code like ('HOIST%')
&lt;FONT size="5" color="#FF00FF"&gt;&lt;STRONG&gt;and&lt;/STRONG&gt;&lt;/FONT&gt; t1.client_code in ('IDEM001','IDEM002','IDEM003','IDEM004','IDEM005','IDEM006','VANQUIS215','VANQUIS216','VANQUIS217','VANQUIS218','VANQUIS219')

&lt;/PRE&gt;
&lt;P&gt;If you have a second variable that has the values in the list, then the above would make sense but not for a single variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: End Proc SQL with a QUIT statement, not run. otherwise the procedure continues to run.&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 16:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876268#M38880</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-17T16:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876390#M38886</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp; but it does not come up with any information.&lt;/P&gt;
&lt;P&gt;"NOTE: Table WORK.HOIST_ACCS_TO_TRACK created, with 0 rows and 10 columns."&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 08:23:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876390#M38886</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-05-18T08:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876391#M38887</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; I made the change and removed the second where and ended it with quit; but it does not show any result in the output data.&lt;BR /&gt;"NOTE: Table WORK.HOIST_ACCS_TO_TRACK created, with 0 rows and 10 columns."&lt;BR /&gt;I am looking for both Hoist% and the IDEM and Vanquis. It is not or but I want to includes all Hoist and the specific IDEM and Vanquis.</description>
      <pubDate>Thu, 18 May 2023 08:26:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876391#M38887</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-05-18T08:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876395#M38891</link>
      <description>&lt;P&gt;You can have only&amp;nbsp;&lt;U&gt;one&lt;/U&gt; WHERE clause in a SELECT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where t1.client_code like ('HOIST%')
and t1.client_code in ('IDEM001','IDEM002','IDEM003','IDEM004','IDEM005','IDEM006','VANQUIS215','VANQUIS216','VANQUIS217','VANQUIS218','VANQUIS219')
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SQL statements are executed immediately, so no RUN is needed. Terminate the SQL procedure with a QUIT statement.&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 09:18:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876395#M38891</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-18T09:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876396#M38892</link>
      <description>&lt;P&gt;Post example data in usable form (DATA step with DATALINES,&amp;nbsp;&lt;STRONG&gt;do not skip this!&lt;/STRONG&gt;), so we can test your code.&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 09:20:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876396#M38892</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-18T09:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876397#M38893</link>
      <description>&lt;P&gt;I tried doing this but it does not produce any output results. Please check the log.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;29         proc sql;
30         create table Hoist_Accs_To_Track as
31         	(select	t3.icustomerid,
32         			t1.debt_code,
33         			t1.client_code,
34         			t1.Rep_code,
35         			t2.Accountstatus,
36         			t2.rep_descrn as Rep_Description,
37         			t1.dt_curbal as Balance,
38         			t1.dt_debtval as Orig_Balance,
39         			datepart(t1.dt_rep_init_date) as Rep_Entry_Date format date9.,
40         			datepart(t1.dt_datinstr) as Bookon_Date format date9.
41         			from p2scflow.debt as t1
42         				left join p2scflow.repcode as t2 on t1.rep_code = t2.rep_code
43         				left join p2scflow.debtcust as t3 on t1.debt_code = t3.debt_code
44         				where t1.client_code like ('HOIST%')
45         and t1.client_code in
45       ! ('IDEM001','IDEM002','IDEM003','IDEM004','IDEM005','IDEM006','VANQUIS215','VANQUIS216','VANQUIS217','VANQUIS218','VANQUIS
45       ! 219'));
NOTE: Table WORK.HOIST_ACCS_TO_TRACK created, with 0 rows and 10 columns.

46         					quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 May 2023 09:23:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876397#M38893</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-05-18T09:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876398#M38894</link>
      <description>&lt;P&gt;Please read my post again, with more diligence.&lt;/P&gt;
&lt;P&gt;We cannot verify your code without data.&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 09:34:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876398#M38894</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-18T09:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876399#M38895</link>
      <description>Ok no problem. I don't have a sample data as this is the first code I am writing to get the data. From the code you can see that I am trying to get data from different datasets like debt, repcode and debtcust tables.</description>
      <pubDate>Thu, 18 May 2023 09:45:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876399#M38895</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-05-18T09:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876400#M38896</link>
      <description>&lt;P&gt;Your WHERE clause uses only columns from&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;p2scflow.debt&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so we must see examples for the two columns from this dataset used in the WHERE. Your code looks OK, so the reason for not getting any results &lt;STRONG&gt;is in the data&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 09:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876400#M38896</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-18T09:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876405#M38898</link>
      <description>&lt;P&gt;1) How about starting with:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select distinct t1.client_code
from from p2scflow.debt as t1
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to see if the values you are looking for are in the data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) Your condition is always false&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where t1.client_code like ('HOIST%')
 and t1.client_code in
('IDEM001','IDEM002','IDEM003','IDEM004','IDEM005','IDEM006','VANQUIS215','VANQUIS216','VANQUIS217','VANQUIS218','VANQUIS219'));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the none of elements from your "long" list starts with "HOIST".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My suggestions:&lt;/P&gt;
&lt;P&gt;a) If you get the list from 1) see if the values are in upper case letters. Possibly you need to do:&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;upcase(strip(t1.client_code))&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;b) There is a chance you need to replace&amp;nbsp;&lt;CODE class=" language-sas"&gt;and&lt;/CODE&gt; with &lt;CODE class=" language-sas"&gt;or&lt;/CODE&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 10:21:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876405#M38898</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-05-18T10:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876409#M38900</link>
      <description>Thank you. I have tried Hoist% and the IDEM, vanquis separately and they all comes in the output data when I run either Hoist or IDEM, Vanquis separately. But I wanted all the Hoist client code and Idem, Vanquis also with the Hoist and when I try to do that it does not show the output data. Now I am thinking of adding all the Hoist ones first and then create another table to add the Idem and Vanquis client code.</description>
      <pubDate>Thu, 18 May 2023 10:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876409#M38900</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-05-18T10:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876410#M38901</link>
      <description>&lt;P&gt;Read the points a) and&amp;nbsp; b) from my post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;where upcase(strip(t1.client_code)) like 'HOIST%'
 OR upcase(strip(t1.client_code)) in
('IDEM001','IDEM002','IDEM003','IDEM004','IDEM005','IDEM006','VANQUIS215','VANQUIS216','VANQUIS217','VANQUIS218','VANQUIS219')&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 18 May 2023 10:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876410#M38901</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-05-18T10:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use Like and In function in a where statement together?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876424#M38905</link>
      <description>Thank you. Your solution worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 18 May 2023 12:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-I-use-Like-and-In-function-in-a-where-statement-together/m-p/876424#M38905</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-05-18T12:16:38Z</dc:date>
    </item>
  </channel>
</rss>

