<?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: Help cannot figure out why i am getting:  ERROR 22-322: Syntax error, expecting one of the follo in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740715#M231431</link>
    <description>&lt;P&gt;If possible, please provide the code as well.&lt;BR /&gt;From the output location in the error log, it seems to be an error in the connect to statement, do you get the same error by executing just this statement in proc sql?&lt;/P&gt;</description>
    <pubDate>Wed, 12 May 2021 04:25:10 GMT</pubDate>
    <dc:creator>japelin</dc:creator>
    <dc:date>2021-05-12T04:25:10Z</dc:date>
    <item>
      <title>Help cannot figure out why i am getting:  ERROR 22-322: Syntax error, expecting one of the following</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740706#M231423</link>
      <description>&lt;P&gt;I put in the MPRINT option and it shows the macro statement.&amp;nbsp; I cannot figure out why i am getting the errors. can anyone spot the errors&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MPRINT(FINALLOAD):   connect to teradata as eixx (username="bdmdxxx"
password="{SAS002}AXX" tdpid=TDP1 mode=teradata
fastload=yes);
ERROR 22-322: Syntax error, expecting one of the following: ;, (, ',', ANSIMISS, CROSS, EXCEPT, FULL,
              GROUP, HAVING, INNER, INTERSECT, JOIN, LEFT, NATURAL, NOMISS, ORDER, OUTER, RIGHT,
              UNION, WHERE.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
MPRINT(FINALLOAD):   create table EIWORK05.CMIHistKygjtest as select * from connection to eiwp
(select MAX(baseid) as maxhistky FROM ( SELECT COALESCE(MAX(hist_ky), 0) AS baseid FROM
HISTORYgjtest UNION all SELECT COALESCE(MAX(hist_ky), 0) AS baseid FROM
History_gjtestwae ) as foo ) WITH DATA NO PRIMARY INDEX;
ERROR 22-322: Syntax error, expecting one of the following: (, SELECT, SET, VALUES.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: ;, VALUES.
ERROR 76-322: Syntax error, statement will be ignored.
MPRINT(FINALLOAD):   insert into HISTORYgjtest ("hist_ky,
cust_id, cust_id_type, cell_ky,as_of_dt,      insrt_dt_tm") SELECT (select maxhistky from) +
pr.hist_ky_add as hist_ky, "pr.cust_id,pr.cust_id_type,pr.cell_ky," (SELECT AS_OF_DT from
WAE_CALENDAR where MO_AGO = 0) as as_of_dt, CAST(CURRENT_TIMESTAMP(0) AS
TIMESTAMP(0)) AS insrt_dt_tm FROM (select "cust_id,cust_id_type,cell_ky," rank(cust_id ||
cust_id_type || cast(cell_ky as varchar(16))asc) as hist_ky_add from
CHD_LOAD_W16 ) pr;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 May 2021 03:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740706#M231423</guid>
      <dc:creator>Gayle</dc:creator>
      <dc:date>2021-05-12T03:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Help cannot figure out why i am getting:  ERROR 22-322: Syntax error, expecting one of the follo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740715#M231431</link>
      <description>&lt;P&gt;If possible, please provide the code as well.&lt;BR /&gt;From the output location in the error log, it seems to be an error in the connect to statement, do you get the same error by executing just this statement in proc sql?&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 04:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740715#M231431</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-05-12T04:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help cannot figure out why i am getting:  ERROR 22-322: Syntax error, expecting one of the follo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740738#M231444</link>
      <description>&lt;P&gt;We don't see enough to comment on the connection error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;About the query, after formatting it a bit (why the random letter cases?) it looks like you wan to run this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table EIWORK05.CMIHistKygjtest as 
select * 
from connection to eiwp
 ( &lt;FONT color="#0000FF"&gt;select MAX(baseid) as maxhistky 
   FROM ( SELECT COALESCE(MAX(hist_ky), 0) AS baseid 
          FROM HISTORYgjtest 
            UNION all 
          SELECT COALESCE(MAX(hist_ky), 0) AS baseid 
          FROM History_gjtestwae 
        ) as foo&lt;/FONT&gt; 
 )
 WITH DATA NO PRIMARY INDEX;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The part in blue is Teradata code, the part in black is SAS code. SAS doesn't support the&amp;nbsp;&amp;nbsp;&lt;FONT face="courier new,courier"&gt;WITH&amp;nbsp;&lt;/FONT&gt; keyword.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 07:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740738#M231444</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-05-12T07:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Help cannot figure out why i am getting:  ERROR 22-322: Syntax error, expecting one of the follo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740762#M231455</link>
      <description>&lt;P&gt;Compare this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;connect to teradata as eixx&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;with this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select * from connection to eiwp&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You need to use the same connection name in both statements.&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 11:15:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740762#M231455</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-12T11:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help cannot figure out why i am getting:  ERROR 22-322: Syntax error, expecting one of the follo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740779#M231464</link>
      <description>&lt;P&gt;It might be easier to see the issue without the macro wrapper.&amp;nbsp; SAS will definitely be able to place the error message more closely to the statement that is causing issue.&lt;/P&gt;
&lt;P&gt;But just reformatting the line from the SAS log is looks clear you have added TERADATA syntax into your SAS code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table EIWORK05.CMIHistKygjtest as 
select * from connection to eiwp
(select MAX(baseid) as maxhistky 
 FROM
  ( SELECT COALESCE(MAX(hist_ky), 0) AS baseid 
    FROM HISTORYgjtest 
    UNION all 
    SELECT COALESCE(MAX(hist_ky), 0) AS baseid 
    FROM History_gjtestwae 
  ) as foo 
) WITH DATA NO PRIMARY INDEX;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This part:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WITH DATA NO PRIMARY INDEX&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is Teradata SQL and is not going be understood by the SAS CREATE TABLE statement.&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 12:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740779#M231464</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-12T12:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help cannot figure out why i am getting:  ERROR 22-322: Syntax error, expecting one of the follo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740793#M231470</link>
      <description>i did and the same error occurs</description>
      <pubDate>Wed, 12 May 2021 13:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740793#M231470</guid>
      <dc:creator>Gayle</dc:creator>
      <dc:date>2021-05-12T13:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help cannot figure out why i am getting:  ERROR 22-322: Syntax error, expecting one of the follo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740811#M231478</link>
      <description>do you know what I can put instead of:&lt;BR /&gt;WITH DATA NO PRIMARY INDEX what is the equivalent</description>
      <pubDate>Wed, 12 May 2021 14:51:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740811#M231478</guid>
      <dc:creator>Gayle</dc:creator>
      <dc:date>2021-05-12T14:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Help cannot figure out why i am getting:  ERROR 22-322: Syntax error, expecting one of the follo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740816#M231480</link>
      <description>let me try to that thanks!</description>
      <pubDate>Wed, 12 May 2021 15:06:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740816#M231480</guid>
      <dc:creator>Gayle</dc:creator>
      <dc:date>2021-05-12T15:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Help cannot figure out why i am getting:  ERROR 22-322: Syntax error, expecting one of the follo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740817#M231481</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/367603"&gt;@Gayle&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;do you know what I can put instead of:&lt;BR /&gt;WITH DATA NO PRIMARY INDEX what is the equivalent&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just remove it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The WITH DATA part is quirky Teradata syntax, without it the CREATE TABLE statement makes the table based on the variables the query generates but does not actual write the query results into the new table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The NO PRIMARY INDEX is needed in Teradata because of how they partition the data into multi storage/compute nodes for parallelization.&amp;nbsp; Since this query only extracts one observation it is not even needed if you were making the table in Teradata.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 15:08:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740817#M231481</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-12T15:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help cannot figure out why i am getting:  ERROR 22-322: Syntax error, expecting one of the follo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740830#M231489</link>
      <description>ok I commented out everything but the connection and it works. so I know it it not that! thanks I will continue in this way so I can see what is creating the error. Thanks for the suggestion</description>
      <pubDate>Wed, 12 May 2021 15:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740830#M231489</guid>
      <dc:creator>Gayle</dc:creator>
      <dc:date>2021-05-12T15:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help cannot figure out why i am getting:  ERROR 22-322: Syntax error, expecting one of the follo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740847#M231495</link>
      <description>ok thank you will try that</description>
      <pubDate>Wed, 12 May 2021 16:13:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-cannot-figure-out-why-i-am-getting-ERROR-22-322-Syntax/m-p/740847#M231495</guid>
      <dc:creator>Gayle</dc:creator>
      <dc:date>2021-05-12T16:13:37Z</dc:date>
    </item>
  </channel>
</rss>

