<?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: Teradata execute: Syntax error: expected something between the 'SELECT' keyword and the e in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819221#M323388</link>
    <description>&lt;P&gt;Thanks i changed the quit to be outside of the loop.&amp;nbsp; .&amp;nbsp; The %PUT at the else just informs of a an empty controlcell dataset.&amp;nbsp; I indicate below where the macro is invoked.&amp;nbsp; when i run this it is not resolving&amp;nbsp; the &lt;STRONG&gt;test&lt;/STRONG&gt; and &lt;STRONG&gt;control&lt;/STRONG&gt; macro variables. How do I get those to resolve?&lt;/P&gt;
&lt;P&gt;error messages:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WARNING: Apparent symbolic reference TEST not resolved.
SYMBOLGEN:  Macro variable I resolves to 18
WARNING: Apparent symbolic reference CONTROL not resolved.
SYMBOLGEN:  Macro variable I resolves to 18
MPRINT(CNTLCELLENTRYTEST):   execute(INSERT INTO p_wae_u_work_05.CHD_TEST_X_CONTROL_test (cell_ky, comparison_ky, as_of_dt,
insrt_dt_tm) SELECT &amp;amp;test.18, &amp;amp;control.18, as_of_dt, CAST(CURRENT_TIMESTAMP(0) AS TIMESTAMP(0)) FROM (SELECT AS_OF_DT FROM
CORE_V2.WAE_CALENDAR WHERE MO_AGO = 0) dtl) by eiwp;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro cntlcellentrytest;
        %put &amp;amp;=controlcellobs.;
        %if &amp;amp;controlcellobs &amp;gt; 0 %then
                %do;
                        %put "here in do";
                 proc sql;
                  select test, control into :test1 -, :control1 -  from work.controlcell;
                 connect to teradata as eiwp (username=&amp;amp;a. password=&amp;amp;b. tdpid=&amp;amp;EIWP_TDPID. mode=teradata fastload=yes);
                        * select test, control into :test1 -, :control1 -  from work.controlcell;
                        %put _global_;
                        %do i=1 %to &amp;amp;controlcellobs;
                           execute(INSERT INTO p_wae_u_work_05.CHD_TEST_X_CONTROL_test
                           (cell_ky, comparison_ky, as_of_dt, insrt_dt_tm)
                           SELECT
                           &amp;amp;test.&amp;amp;i,
                           &amp;amp;control.&amp;amp;i,
                           as_of_dt,
                           CAST(CURRENT_TIMESTAMP(0) AS TIMESTAMP(0))
                           FROM
                          (SELECT AS_OF_DT
                           FROM WAE_D_CORE_V2.WAE_CALENDAR
                           WHERE MO_AGO = 0) etl)   by eiwp;
                        %end;
                        quit;
                %end;
        %else;
                %put 'No entries in control cells';

%mend cntlcellentrytest;

%cntlcellentrytest;   ****here is where the macro is invoked
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 20 Jun 2022 22:56:12 GMT</pubDate>
    <dc:creator>Gayle</dc:creator>
    <dc:date>2022-06-20T22:56:12Z</dc:date>
    <item>
      <title>ERROR: Teradata execute: Syntax error: expected something between the 'SELECT' keyword and the end o</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819192#M323372</link>
      <description>&lt;PRE&gt;I am gettting the error below but cannot figure out why.  Please look and advise the code is below.&lt;/PRE&gt;
&lt;P&gt;ERROR: Teradata execute: Syntax error: expected something between the 'SELECT' keyword and the end of the request.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;
%put &amp;amp;=controlcellobs.;
%macro cntlcellentrytest;
        %put &amp;amp;=controlcellobs.;
        %if &amp;amp;controlcellobs &amp;gt; 0 %then
                %do;
                        %put "here in do";
                 proc sql;
                 connect to teradata as eiwp (username=&amp;amp;a. password=&amp;amp;b. tdpid=&amp;amp;EIWP_TDPID. mode=teradata fastload=yes);
                         select test, control into :test1 -, :control1 -  from work.controlcell;
                        %put _global_;
                        %do i=1 %to sqlobs;
                           execute(INSERT INTO work_05.CHD_TEST_X_CONTROL_test
                           (cell_ky, comparison_ky, as_of_dt, insrt_dt_tm)
                           SELECT
                           &amp;amp;test.&amp;amp;i.,
                           &amp;amp;control.&amp;amp;i.,
                           as_of_dt,
                           CAST(CURRENT_TIMESTAMP(0) AS TIMESTAMP(0))
                           FROM
                          (SELECT AS_OF_DT
                           FROM CORE_V2.WAE_CALENDAR
                           WHERE MO_AGO = 0) etl)   by eiwp;
                        quit;
                        %end;
                
                %end;
        %else;
                %put 'No entries in control cells';

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 19:32:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819192#M323372</guid>
      <dc:creator>Gayle</dc:creator>
      <dc:date>2022-06-20T19:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Teradata execute: Syntax error: expected something between the 'SELECT' keyword and the e</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819210#M323381</link>
      <description>&lt;P&gt;Rerun your program after adding - options mprint; - at the top. Then we can see the actual statements being executed. Not a SAS problem but a Teradata syntax problem.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 21:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819210#M323381</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-06-20T21:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Teradata execute: Syntax error: expected something between the 'SELECT' keyword and the e</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819213#M323383</link>
      <description>&lt;P&gt;Where is the rest of the definition of that macro?&lt;BR /&gt;Where is the code that actually called that macro?&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Try aligning the indentation so it is a little easier to see what the code is doing.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Try using a smaller tab size also so that the lines do not get so far shifted to the right that they are hard for humans to scan and align.&lt;/LI&gt;
&lt;LI&gt;It also helps to indent the actual SAS code the macro is generating independently of the MACRO code that is used to generate it.&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro cntlcellentrytest;
%put &amp;amp;=controlcellobs.;
%if &amp;amp;controlcellobs &amp;gt; 0 %then %do;
  %put "here in do";
proc sql;
connect to teradata as eiwp (username=&amp;amp;a. password=&amp;amp;b. tdpid=&amp;amp;EIWP_TDPID. mode=teradata fastload=yes);
select test
     , control 
  into :test1 -
     , :control1 -  
  from work.controlcell
;

  %do i=1 %to sqlobs;
execute
 (INSERT INTO work_05.CHD_TEST_X_CONTROL_test(cell_ky, comparison_ky, as_of_dt, insrt_dt_tm)
  SELECT
     &amp;amp;test.&amp;amp;i.
    ,&amp;amp;control.&amp;amp;i.
    ,as_of_dt
    ,CAST(CURRENT_TIMESTAMP(0) AS TIMESTAMP(0))
  FROM
      (SELECT AS_OF_DT
        FROM CORE_V2.WAE_CALENDAR
        WHERE MO_AGO = 0
      ) etl
 )   
by eiwp;
quit;
  %end;
%end;
%else;
%put 'No entries in control cells';
/* What goes here? */
%mend cntlcellentrytest;

%let controlcellobs=what value should this have?
%put &amp;amp;=controlcellobs.;
%cntlcellentrytest;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now it is much easier to see that the QUIT statement that ends the PROC SQL step is INSIDE the %DO loop.&amp;nbsp; So if SQLOBS is larger than 1 you will have problems with the SAS code you generated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also why is the last %PUT statement being run unconditionally?&amp;nbsp; Should that be inside of a %ELSE block?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you really have a TERADATA schema named WORK_05?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 21:57:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819213#M323383</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-20T21:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Teradata execute: Syntax error: expected something between the 'SELECT' keyword and the e</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819221#M323388</link>
      <description>&lt;P&gt;Thanks i changed the quit to be outside of the loop.&amp;nbsp; .&amp;nbsp; The %PUT at the else just informs of a an empty controlcell dataset.&amp;nbsp; I indicate below where the macro is invoked.&amp;nbsp; when i run this it is not resolving&amp;nbsp; the &lt;STRONG&gt;test&lt;/STRONG&gt; and &lt;STRONG&gt;control&lt;/STRONG&gt; macro variables. How do I get those to resolve?&lt;/P&gt;
&lt;P&gt;error messages:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WARNING: Apparent symbolic reference TEST not resolved.
SYMBOLGEN:  Macro variable I resolves to 18
WARNING: Apparent symbolic reference CONTROL not resolved.
SYMBOLGEN:  Macro variable I resolves to 18
MPRINT(CNTLCELLENTRYTEST):   execute(INSERT INTO p_wae_u_work_05.CHD_TEST_X_CONTROL_test (cell_ky, comparison_ky, as_of_dt,
insrt_dt_tm) SELECT &amp;amp;test.18, &amp;amp;control.18, as_of_dt, CAST(CURRENT_TIMESTAMP(0) AS TIMESTAMP(0)) FROM (SELECT AS_OF_DT FROM
CORE_V2.WAE_CALENDAR WHERE MO_AGO = 0) dtl) by eiwp;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro cntlcellentrytest;
        %put &amp;amp;=controlcellobs.;
        %if &amp;amp;controlcellobs &amp;gt; 0 %then
                %do;
                        %put "here in do";
                 proc sql;
                  select test, control into :test1 -, :control1 -  from work.controlcell;
                 connect to teradata as eiwp (username=&amp;amp;a. password=&amp;amp;b. tdpid=&amp;amp;EIWP_TDPID. mode=teradata fastload=yes);
                        * select test, control into :test1 -, :control1 -  from work.controlcell;
                        %put _global_;
                        %do i=1 %to &amp;amp;controlcellobs;
                           execute(INSERT INTO p_wae_u_work_05.CHD_TEST_X_CONTROL_test
                           (cell_ky, comparison_ky, as_of_dt, insrt_dt_tm)
                           SELECT
                           &amp;amp;test.&amp;amp;i,
                           &amp;amp;control.&amp;amp;i,
                           as_of_dt,
                           CAST(CURRENT_TIMESTAMP(0) AS TIMESTAMP(0))
                           FROM
                          (SELECT AS_OF_DT
                           FROM WAE_D_CORE_V2.WAE_CALENDAR
                           WHERE MO_AGO = 0) etl)   by eiwp;
                        %end;
                        quit;
                %end;
        %else;
                %put 'No entries in control cells';

%mend cntlcellentrytest;

%cntlcellentrytest;   ****here is where the macro is invoked
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Jun 2022 22:56:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819221#M323388</guid>
      <dc:creator>Gayle</dc:creator>
      <dc:date>2022-06-20T22:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Teradata execute: Syntax error: expected something between the 'SELECT' keyword and the e</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819224#M323389</link>
      <description>&lt;P&gt;Your macro variables need to be changed like this to resolve correctly to test1 and control1:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;     &amp;amp;&amp;amp;test&amp;amp;i.
    ,&amp;amp;&amp;amp;control&amp;amp;i.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Jun 2022 23:16:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819224#M323389</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-06-20T23:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Teradata execute: Syntax error: expected something between the 'SELECT' keyword and the e</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819226#M323391</link>
      <description>Thank you! that resolved the variables</description>
      <pubDate>Mon, 20 Jun 2022 23:25:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819226#M323391</guid>
      <dc:creator>Gayle</dc:creator>
      <dc:date>2022-06-20T23:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Teradata execute: Syntax error: expected something between the 'SELECT' keyword and the e</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819229#M323393</link>
      <description>&lt;P&gt;Why are you still printing the no entries message even when there are entries?&amp;nbsp; Why did you indent the %PUT statement at a different level than the %ELSE and the %IF statement?&amp;nbsp; Just indenting the code does mean that it only runs when the %ELSE clause runs.&amp;nbsp; To do that you need to actually include it in the %ELSE clause.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; %else %put NOTE: No entries in control cells.;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use a %DO /%END block.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%else %do;
    %put NOTE: No entries in control cells.;
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Jun 2022 23:46:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819229#M323393</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-20T23:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Teradata execute: Syntax error: expected something between the 'SELECT' keyword and the e</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819240#M323397</link>
      <description>&lt;P&gt;Thank you ! I was wondering why this was printing despite entries.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 03:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Teradata-execute-Syntax-error-expected-something-between/m-p/819240#M323397</guid>
      <dc:creator>Gayle</dc:creator>
      <dc:date>2022-06-21T03:00:45Z</dc:date>
    </item>
  </channel>
</rss>

