<?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 Calling FEDSQL from call execute loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calling-FEDSQL-from-call-execute-loop/m-p/824705#M325698</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;a simple question:&lt;/P&gt;&lt;P&gt;while trying to run a proc fedsql inside a call execute loop i'm getting a strange error:&lt;/P&gt;&lt;PRE&gt;data _null_;
 a= "MD";
 set GNC.GNC_CAUSES_NO_EDGE_BACK(obs=1);
 call execute('proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL  where id_class ='||a||'; quit;');
run;&lt;/PRE&gt;&lt;P&gt;BTW: the dataset live in a cas library&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting this error:&lt;/P&gt;&lt;PRE&gt;NOTE: There were 1 observations read from the data set GNC.GNC_CAUSES_NO_EDGE_BACK.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

NOTE: CALL EXECUTE generated line.
1         + proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL  where id_class =MD;
1         +                                                                                                                 quit;
ERROR: Column "MD" not found or cannot be accessed
ERROR: Azione interrotta a causa di errori.
ERROR: The FedSQL action was not successful.
NOTE: PROC FEDSQL has set option NOEXEC and will continue to prepare statements.

NOTE: PROCEDURE FEDSQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds&lt;/PRE&gt;&lt;P&gt;I've tested the same code using proc SQL, with no problem, but since the main table is huge i would like to use fedsql (much faster)&lt;/P&gt;&lt;P&gt;I'm on viya 3.5 executed from a local SAS session.&lt;/P&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>Thu, 21 Jul 2022 15:42:43 GMT</pubDate>
    <dc:creator>andrea_magatti</dc:creator>
    <dc:date>2022-07-21T15:42:43Z</dc:date>
    <item>
      <title>Calling FEDSQL from call execute loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-FEDSQL-from-call-execute-loop/m-p/824705#M325698</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;a simple question:&lt;/P&gt;&lt;P&gt;while trying to run a proc fedsql inside a call execute loop i'm getting a strange error:&lt;/P&gt;&lt;PRE&gt;data _null_;
 a= "MD";
 set GNC.GNC_CAUSES_NO_EDGE_BACK(obs=1);
 call execute('proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL  where id_class ='||a||'; quit;');
run;&lt;/PRE&gt;&lt;P&gt;BTW: the dataset live in a cas library&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting this error:&lt;/P&gt;&lt;PRE&gt;NOTE: There were 1 observations read from the data set GNC.GNC_CAUSES_NO_EDGE_BACK.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

NOTE: CALL EXECUTE generated line.
1         + proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL  where id_class =MD;
1         +                                                                                                                 quit;
ERROR: Column "MD" not found or cannot be accessed
ERROR: Azione interrotta a causa di errori.
ERROR: The FedSQL action was not successful.
NOTE: PROC FEDSQL has set option NOEXEC and will continue to prepare statements.

NOTE: PROCEDURE FEDSQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds&lt;/PRE&gt;&lt;P&gt;I've tested the same code using proc SQL, with no problem, but since the main table is huge i would like to use fedsql (much faster)&lt;/P&gt;&lt;P&gt;I'm on viya 3.5 executed from a local SAS session.&lt;/P&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>Thu, 21 Jul 2022 15:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-FEDSQL-from-call-execute-loop/m-p/824705#M325698</guid>
      <dc:creator>andrea_magatti</dc:creator>
      <dc:date>2022-07-21T15:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calling FEDSQL from call execute loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-FEDSQL-from-call-execute-loop/m-p/824707#M325700</link>
      <description>&lt;P&gt;Pretty clear:&lt;/P&gt;
&lt;PRE&gt;1         + proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL  where id_class =MD;&lt;/PRE&gt;
&lt;P&gt;No quotes around MD means SAS is using it as a variable not a literal value.&lt;/P&gt;
&lt;P&gt;You want to generate&lt;/P&gt;
&lt;PRE&gt;proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL  where id_class ='MD';&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; which might be easiest with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; call execute('proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL &lt;BR /&gt; where id_class ='|| &lt;STRONG&gt;quote(a)&lt;/STRONG&gt; ||'; quit;');&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 15:51:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-FEDSQL-from-call-execute-loop/m-p/824707#M325700</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-21T15:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calling FEDSQL from call execute loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-FEDSQL-from-call-execute-loop/m-p/824708#M325701</link>
      <description>&lt;P&gt;Even stranger now:&lt;/P&gt;&lt;P&gt;after using your suggestion, I'm getting the same error:&lt;/P&gt;&lt;PRE&gt;NOTE: CALL EXECUTE generated line.
1         + proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL  where id_class ="MD";
1         +                                                                                                                   quit;
ERROR: Column "MD" not found or cannot be accessed
ERROR: Azione interrotta a causa di errori.
ERROR: The FedSQL action was not successful.&lt;/PRE&gt;&lt;P&gt;It still says that it can't find the column, despite the quote function as:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data _null_;
 a= "MD";
 set GNC.GNC_CAUSES_NO_EDGE_BACK(obs=1);
 call execute('proc fedsql sessref=EG_Session; select distinct id_remi  from GNC.REMI_VOL_2008_2021_FINAL  where id_class ='||quote(a)||'; quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Many thanks for considering my request.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 15:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-FEDSQL-from-call-execute-loop/m-p/824708#M325701</guid>
      <dc:creator>andrea_magatti</dc:creator>
      <dc:date>2022-07-21T15:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calling FEDSQL from call execute loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-FEDSQL-from-call-execute-loop/m-p/824718#M325708</link>
      <description>&lt;P&gt;Show a DIRECT call to fedsql that does work.&lt;/P&gt;
&lt;P&gt;as in not generated by a data step, just the Proc fedsql submitted directly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not familiar with all the stuff that gets involved with the connections. I am assuming the ID_class is a variable in the table GNC.REMI_VOL_2008_2021_FINAL. If not then I'm clueless at this point.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 16:22:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-FEDSQL-from-call-execute-loop/m-p/824718#M325708</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-21T16:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calling FEDSQL from call execute loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-FEDSQL-from-call-execute-loop/m-p/824722#M325711</link>
      <description>&lt;P&gt;PROC FEDSQL is probably treating "MD" as a variable reference and is expecting you to use single quotes for literals.&amp;nbsp; In PROC SQL you have to request this behavior but perhaps it is the default in PROC FEDSQL.&lt;/P&gt;
&lt;P&gt;Tell the QUOTE() function to use single quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;quote(a,"'")&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Jul 2022 16:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-FEDSQL-from-call-execute-loop/m-p/824722#M325711</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-21T16:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calling FEDSQL from call execute loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-FEDSQL-from-call-execute-loop/m-p/824723#M325712</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;Working!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 16:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-FEDSQL-from-call-execute-loop/m-p/824723#M325712</guid>
      <dc:creator>andrea_magatti</dc:creator>
      <dc:date>2022-07-21T16:39:06Z</dc:date>
    </item>
  </channel>
</rss>

