<?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: Syntax error in explicit passthrough in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-explicit-passthrough/m-p/835379#M330273</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp; Following query works fine in SQL server&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    select * from     
(
                SELECT MATRL_NBR
                                  ,CLAS
                                  ,CHRSTC_NM
                                  ,CHRSTC_VAL
                  FROM INPUT_TABLE
) as t1
                PIVOT (
                                max(CHRSTC_VAL)
                                FOR CHRSTC_NM in (IP_BU, IP_BRAND) 
) as t2;
&lt;/PRE&gt;</description>
    <pubDate>Tue, 27 Sep 2022 07:22:44 GMT</pubDate>
    <dc:creator>David_Billa</dc:creator>
    <dc:date>2022-09-27T07:22:44Z</dc:date>
    <item>
      <title>Syntax error in explicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-explicit-passthrough/m-p/835370#M330266</link>
      <description>&lt;P&gt;I'm getting the syntax error when I execute the following code in SAS EG. However it's working fine when I execute in SQL server. What would be the likely cause for the issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql noprint;
  connect to sqlsvr(dsn=KNA_FINLAND
    user="SAS" 
    pwd="SAS002" 
    readbuff=32000);
     create table TEST as
    select * from connection to sqlsvr 
     

(
                SELECT MATRL_NBR
                                  ,CLAS
                                  ,CHRSTC_NM
                                  ,CHRSTC_VAL
                  FROM INPUT_TABLE
) as t1
                PIVOT (
                                max(CHRSTC_VAL)
                                FOR CHRSTC_NM in (IP_BU, IP_BRAND) 
) as t2;
disconnect from sqlsvr;

quit;
&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;31               create table TEST as
32             select * from connection to sqlsvr
33              
34         
35          (
36                         SELECT MATRL_NBR
37                                           ,CLAS
38                                           ,CHRSTC_NM
39                                           ,CHRSTC_VAL
40                           FROM INPUT_TABLE
41         ) as t1
42                         PIVOT (
                           _____
                           22
                           76
ERROR 22-322: Syntax error, expecting one of the following: GROUP, HAVING, ORDER, WHERE.  

ERROR 76-322: Syntax error, statement will be ignored.

43                                         max(CHRSTC_VAL)
44                                         FOR CHRSTC_NM in (IP_BU, IP_BRAND)
45         ) as t2;
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
46         disconnect from sqlsvr;
NOTE: Statement not executed due to NOEXEC option.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 06:17:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-explicit-passthrough/m-p/835370#M330266</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2022-09-27T06:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in explicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-explicit-passthrough/m-p/835378#M330272</link>
      <description>&lt;P&gt;It looks like a parenthesis matching problem.&lt;/P&gt;
&lt;P&gt;Now the PIVOT instruction appears &lt;EM&gt;outside&lt;/EM&gt; the block THAT IS sent to SQL Server.&lt;/P&gt;
&lt;P&gt;How does the code look like when you execute it in SQL Server?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 07:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-explicit-passthrough/m-p/835378#M330272</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2022-09-27T07:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in explicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-explicit-passthrough/m-p/835379#M330273</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp; Following query works fine in SQL server&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    select * from     
(
                SELECT MATRL_NBR
                                  ,CLAS
                                  ,CHRSTC_NM
                                  ,CHRSTC_VAL
                  FROM INPUT_TABLE
) as t1
                PIVOT (
                                max(CHRSTC_VAL)
                                FOR CHRSTC_NM in (IP_BU, IP_BRAND) 
) as t2;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Sep 2022 07:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-explicit-passthrough/m-p/835379#M330273</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2022-09-27T07:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in explicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-explicit-passthrough/m-p/835380#M330274</link>
      <description>&lt;P&gt;Then I think it should look like this (untested):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  connect to sqlsvr(dsn=KNA_FINLAND
    user="SAS" 
    pwd="SAS002" 
    readbuff=32000);
     create table TEST as
    select * from connection to sqlsvr 
     
(select * from     
(
                SELECT MATRL_NBR
                                  ,CLAS
                                  ,CHRSTC_NM
                                  ,CHRSTC_VAL
                  FROM INPUT_TABLE
) as t1
                PIVOT (
                                max(CHRSTC_VAL)
                                FOR CHRSTC_NM in (IP_BU, IP_BRAND) 
) as t2
);
quit&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Sep 2022 07:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Syntax-error-in-explicit-passthrough/m-p/835380#M330274</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2022-09-27T07:35:33Z</dc:date>
    </item>
  </channel>
</rss>

