<?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: ERROR: Expecting a SELECT ?? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798740#M314002</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The non-matching data types were not detected then because the immediately preceding condition threw an ERROR and the SQL compiler stopped right there.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I see what you mean, but I referred to the &lt;EM&gt;first&lt;/EM&gt; of the two PROC SQL steps (which had a clean log) in the initial post when I wrote that the condition using &lt;FONT face="courier new,courier"&gt;eventDate&lt;/FONT&gt; did not cause a type mismatch.&lt;/P&gt;</description>
    <pubDate>Fri, 25 Feb 2022 19:59:23 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2022-02-25T19:59:23Z</dc:date>
    <item>
      <title>ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798688#M313976</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;23         proc sql;
24         create table claims
25         as select
26         cpt,
27         cptdescription,
28         cost,
29         eventDate,
30         icd,
31         icdDescription,
32         providerNPI,
33         providerName,
34         providerSpecialty,
35         memberNo
36         from x.eventLineDetails
37         where providerSpecialty = 'Dermatology'
38         and eventDate between "2020-12-01" and "2021-12-31"
39         and claimatRisk=1;
NOTE: Table WORK.CLAIMS created, with 138947 rows and 10 columns.

40         quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           5.21 seconds
      cpu time            1.73 seconds
      

41         
42         
43         /*from pharmacyEvents table*/
44         
45         proc sql;
46         create table pharmacy
47         as select
48         memberNo,
2                                                          The SAS System                            09:40 Friday, February 25, 2022

49         cost,
50         prescriberNPI,
51         prescriberName,
52         prescriberSpecialty,
53         paidDate
54         from x.pharmacyEvents
55         where prescriberSpecialty in 'Dermatology'
                                        _____________
                                        79
                                        76
ERROR 79-322: Expecting a SELECT.

ERROR 76-322: Syntax error, statement will be ignored.

56         and paidDate between "2020-12-01" and "2021-12-31"
57         and claimatRisk=1;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
58         quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Not sure why it requires a SELECT statement there.&amp;nbsp; The first proc sql works and the second is very similar to that one so not sure why it's erroring out.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Fri, 25 Feb 2022 17:49:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798688#M313976</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2022-02-25T17:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798693#M313979</link>
      <description>When you compare to a single value, use = instead of IN. The IN operator needs a list enclosed in parentheses.</description>
      <pubDate>Fri, 25 Feb 2022 17:56:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798693#M313979</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-25T17:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798694#M313980</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where prescriberSpecialty in ('Dermatology')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or in this case, since there is only one item in the IN clause you could also use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where prescriberSpecialty eq 'Dermatology'&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Feb 2022 17:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798694#M313980</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-25T17:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798705#M313986</link>
      <description>And that error is generated because "IN" in SQL is typically followed by either a list of values or a subquery (SELECT) that generates a list of values. &lt;BR /&gt;&lt;BR /&gt;SAS doesn't know which one you're trying to do, so the error doesn't quite align with what you're trying to accomplish in this case.</description>
      <pubDate>Fri, 25 Feb 2022 18:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798705#M313986</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-25T18:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798706#M313987</link>
      <description>&lt;P&gt;I tried the equal sign, and it gave me this (as if I'm still using the IN operator):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;23         proc sql;
24         create table pharmacy
25         as select
26         memberNo,
27         cost,
28         prescriberNPI,
29         prescriberName,
30         prescriberSpecialty,
31         paidDate
32         from x.pharmacyEvents
33         where prescriberSpecialty = 'Dermatology'
34         and paidDate between "2020-12-01" and "2021-12-31"
35         and claimatRisk=1;
ERROR: Expression using IN has components that are of different data types.
NOTE: The IN referred to may have been transformed from an OR to an IN at some point during PROC SQL WHERE clause optimization.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
36         quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.19 seconds
      cpu time            0.03 seconds
      &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 18:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798706#M313987</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2022-02-25T18:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798707#M313988</link>
      <description>yeah i tried equal sign too and it gave an error still</description>
      <pubDate>Fri, 25 Feb 2022 18:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798707#M313988</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2022-02-25T18:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798711#M313991</link>
      <description>Well, it says the types mismatch. That means PrescriberSpeciality is likely a numeric column not a character column. What is the type and format on that column? It may be numeric with a format applied to make it look like Dermatology?</description>
      <pubDate>Fri, 25 Feb 2022 18:32:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798711#M313991</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-25T18:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798716#M313993</link>
      <description>&lt;P&gt;I think it's more likely that&amp;nbsp;&lt;FONT face="courier new,courier"&gt;paidDate&lt;/FONT&gt; is a numeric variable containing SAS date values (as it should) so that the date condition should read&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;paidDate between &lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;'01DEC2020'd&lt;/FONT&gt;&lt;/STRONG&gt; and &lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;'31DEC2021'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Looking at your first PROC SQL step where the similar condition&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;eventDate between "2020-12-01" and "2021-12-31"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;did &lt;EM&gt;not&lt;/EM&gt; cause a type mismatch I'm not so sure that &lt;FONT face="courier new,courier"&gt;paidDate&lt;/FONT&gt; really contains &lt;EM&gt;SAS date values&lt;/EM&gt;, only that &lt;FONT face="courier new,courier"&gt;eventDate&lt;/FONT&gt; does &lt;EM&gt;not&lt;/EM&gt; contain SAS date values. So you should check what kind of numeric values &lt;FONT face="courier new,courier"&gt;paidDate&lt;/FONT&gt; contains. The reason why I think they are numeric is that I would expect type mismatches regarding&amp;nbsp;&lt;FONT face="courier new,courier"&gt;prescriberSpecialty&lt;/FONT&gt; or&amp;nbsp;&lt;FONT face="courier new,courier"&gt;claimatRisk&lt;/FONT&gt;&amp;nbsp;to result in the error message&lt;/P&gt;
&lt;PRE&gt;ERROR: Expression using equals (=) has components that are of different data types.&lt;/PRE&gt;
&lt;P&gt;which is different from what you've shown.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 19:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798716#M313993</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-02-25T19:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798717#M313994</link>
      <description>&lt;P&gt;Why are your padDate values strings/character?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;and paidDate between "2020-12-01" and "2021-12-31"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That doesn't look right, I would expect them to be SAS date values&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 18:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798717#M313994</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2022-02-25T18:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798733#M313999</link>
      <description>&lt;P&gt;Most likely because you use incorrect date literals. They must be of the form&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'01jan2022'd&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(DATE9. format, enclosed in quotes with &amp;nbsp;an immediately trailing d)&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 19:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798733#M313999</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-25T19:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798734#M314000</link>
      <description>&lt;P&gt;The non-matching data types were not detected then because the immediately preceding condition threw an ERROR and the SQL compiler stopped right there.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 19:48:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798734#M314000</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-25T19:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798740#M314002</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The non-matching data types were not detected then because the immediately preceding condition threw an ERROR and the SQL compiler stopped right there.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I see what you mean, but I referred to the &lt;EM&gt;first&lt;/EM&gt; of the two PROC SQL steps (which had a clean log) in the initial post when I wrote that the condition using &lt;FONT face="courier new,courier"&gt;eventDate&lt;/FONT&gt; did not cause a type mismatch.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 19:59:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798740#M314002</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-02-25T19:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798746#M314004</link>
      <description>Thank you, it was the dates!</description>
      <pubDate>Fri, 25 Feb 2022 21:54:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798746#M314004</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2022-02-25T21:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798747#M314005</link>
      <description>&lt;P&gt;That one comes from a different dataset, so this must have strings as "dates".&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 22:08:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798747#M314005</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-25T22:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expecting a SELECT ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798766#M314012</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/290946"&gt;@bhca60&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you, it was the dates!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You're welcome. However, later readers of this thread might be confused about the accepted solution as it is unrelated to the error message in the subject line and in your initial post. (The date issue surfaced only when you corrected the first error.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think it would be more appropriate if you marked one of the first three replies, which answered the original question, as the accepted solution.&amp;nbsp;It's very easy to change this: Select the most helpful post&amp;nbsp;as the solution after clicking&amp;nbsp;"Not the Solution" in the option menu (see icon below) of the current solution.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="show_option_menu.png" style="width: 133px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/68941i484788484B2F62A4/image-size/large?v=v2&amp;amp;px=999" role="button" title="show_option_menu.png" alt="show_option_menu.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 23:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expecting-a-SELECT/m-p/798766#M314012</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-02-25T23:26:01Z</dc:date>
    </item>
  </channel>
</rss>

