<?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: Not able to execute 'CALL Execute' statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691407#M210446</link>
    <description>What are you trying to do here?&lt;BR /&gt;Wouldn't the following do what you want? Why the need for the CALL EXECUTE? &lt;BR /&gt;&lt;BR /&gt;%include 'C:\SAS\SAS9.1\dquality\sample.*.sas';</description>
    <pubDate>Tue, 13 Oct 2020 20:58:28 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-10-13T20:58:28Z</dc:date>
    <item>
      <title>Not able to execute 'CALL Execute' statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691368#M210440</link>
      <description>&lt;P&gt;I have created a small code but I don't understand why it is not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%macro sn;&lt;BR /&gt;filename x 'C:\SAS\SAS9.1\dquality\sample\*.sas';&lt;BR /&gt;CALL EXECUTE (' %INCLUDE "&amp;amp;x"; ');&lt;BR /&gt;%mend sn;&lt;BR /&gt;%sn;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error:&lt;/STRONG&gt;1 CALL Execute('%INCLUDE "C:\SAS\SAS9.1\dquality\sample\dqanalyz.sas";');&lt;BR /&gt;----&lt;BR /&gt;180&lt;BR /&gt;MPRINT(SN): CALL Execute('%INCLUDE "C:\SAS\SAS9.1\dquality\sample\dqanalyz.sas";');&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;MLOGIC(SN): Ending execution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 19:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691368#M210440</guid>
      <dc:creator>anmolk171</dc:creator>
      <dc:date>2020-10-13T19:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to execute 'CALL Execute' statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691370#M210441</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let X = %STR('C:\SAS\SAS9.1\dquality\sample\*.sas');
&lt;BR /&gt;%macro sn;
CALL EXECUTE (' %INCLUDE "&amp;amp;x"; ');
%mend sn;
%sn;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Try taking the filename out of the macro and making it a %LET as shown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And %sn needs to be &lt;EM&gt;inside&lt;/EM&gt; a Data step, like so:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA	_NULL_;
    %sn;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 19:29:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691370#M210441</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-13T19:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to execute 'CALL Execute' statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691371#M210442</link>
      <description>Thanks Jim for your response but I am getting the same error</description>
      <pubDate>Tue, 13 Oct 2020 19:30:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691371#M210442</guid>
      <dc:creator>anmolk171</dc:creator>
      <dc:date>2020-10-13T19:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to execute 'CALL Execute' statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691373#M210443</link>
      <description>&lt;P&gt;First make sure you moved %sn &lt;EM&gt;inside&amp;nbsp;&lt;/EM&gt;a DATA step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, please post your code and your log using the buttons in the reply window.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_0-1602617538766.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50634i6F135EE786AB63AB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jimbarbour_0-1602617538766.png" alt="jimbarbour_0-1602617538766.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 19:33:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691373#M210443</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-13T19:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to execute 'CALL Execute' statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691374#M210444</link>
      <description>&lt;P&gt;Oh, wait.&amp;nbsp; I see the problem.&amp;nbsp; You have an asterisk in your "X".&amp;nbsp; You can't do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me code something up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 19:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691374#M210444</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-13T19:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to execute 'CALL Execute' statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691377#M210445</link>
      <description>&lt;P&gt;OK, try this code (below).&amp;nbsp; &lt;STRONG&gt;CAUTION&lt;/STRONG&gt;:&amp;nbsp; This code will&amp;nbsp;&lt;EM&gt;execute&lt;/EM&gt; every program in the folder you point to.&amp;nbsp; You are going to run &lt;EM&gt;every&lt;/EM&gt; program in that directory if you use this code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to double check that I've set the Path and the Drive correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET	Path	=	C:\SAS\SAS9.1\dquality\sample;
%LET	Drive	=	C;

FILENAME	Pgm_List	PIPE	"cd ""&amp;amp;Path"" &amp;amp;&amp;amp; &amp;amp;Drive: &amp;amp;&amp;amp; dir *.sas /a /b";

DATA	_NULL_;
	INFILE	Pgm_List;
	INPUT	Pgm_Name	:	$256.;
	Pgm_Name	=	CATS("&amp;amp;Path", "\", Pgm_Name);
	PUTLOG	"NOTE:  "  Pgm_Name=;
	CALL EXECUTE (CATX(' ', '%INCLUDE"', Pgm_Name, '";'));
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Oct 2020 19:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691377#M210445</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-13T19:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to execute 'CALL Execute' statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691407#M210446</link>
      <description>What are you trying to do here?&lt;BR /&gt;Wouldn't the following do what you want? Why the need for the CALL EXECUTE? &lt;BR /&gt;&lt;BR /&gt;%include 'C:\SAS\SAS9.1\dquality\sample.*.sas';</description>
      <pubDate>Tue, 13 Oct 2020 20:58:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691407#M210446</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-13T20:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to execute 'CALL Execute' statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691412#M210447</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;What are you trying to do here?&lt;BR /&gt;Wouldn't the following do what you want? Why the need for the CALL EXECUTE? &lt;BR /&gt;&lt;BR /&gt;%include 'C:\SAS\SAS9.1\dquality\sample.&lt;FONT size="5"&gt;&lt;STRONG&gt;*&lt;/STRONG&gt;&lt;/FONT&gt;.sas';&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would that work with a wildcard like that?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would agree that a CALL EXECUTE isn't strictly necessary here.&amp;nbsp; I have used CALL EXECUTE to format the commands for a SYSTASK to launch a bunch of SAS jobs that each write their own log and essentially function as independent jobs once launched.&amp;nbsp; I've found that to be useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 21:09:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691412#M210447</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-13T21:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to execute 'CALL Execute' statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691421#M210448</link>
      <description>Yes, %INCLUDE and FILENAME both allow the wildcard in my experience.</description>
      <pubDate>Tue, 13 Oct 2020 21:59:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691421#M210448</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-13T21:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to execute 'CALL Execute' statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691422#M210449</link>
      <description>&lt;P&gt;Oh, fantastic.&amp;nbsp; I've used a wildcard on a Filename before but never an Include.&amp;nbsp; Thank you for that.&amp;nbsp; Perhaps it will come in handy some day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 22:01:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691422#M210449</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-13T22:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to execute 'CALL Execute' statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691649#M210542</link>
      <description>I have found another workaround to do this but really appreciate it if you guys can tell what's wrong with the code.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;Anmol&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Oct 2020 19:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691649#M210542</guid>
      <dc:creator>anmolk171</dc:creator>
      <dc:date>2020-10-14T19:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to execute 'CALL Execute' statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691658#M210545</link>
      <description>&lt;P&gt;You defined a fileref named X and then later tried to use a macro variable named X that you never defined.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You cannot use CALL EXECUTE() outside of a DATA step.&amp;nbsp; Your program does appear to need a data step.&amp;nbsp; It also doesn't need to be wrapped in a macro definition either.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead just use the fileref in the %INCLUDE statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename x 'C:\SAS\SAS9.1\dquality\sample\*.sas';
%INCLUDE X ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or skip the FILENAME and use the path in the %INCLUDE statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%INCLUDE 'C:\SAS\SAS9.1\dquality\sample\*.sas';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could also point the fileref at the folder.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename x 'C:\SAS\SAS9.1\dquality\sample\';
%INCLUDE X('*.sas');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But watch out if you are using Windows because of how it handles extensions longer than three characters.&amp;nbsp; The pattern *.sas will also match *.sas7bdat and *.sas7bcat.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 20:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Not-able-to-execute-CALL-Execute-statement/m-p/691658#M210545</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-14T20:04:30Z</dc:date>
    </item>
  </channel>
</rss>

