<?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: Call EXECUTE odditiy in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Call-EXECUTE-odditiy/m-p/905168#M357527</link>
    <description>&lt;P&gt;Here is another one.&lt;/P&gt;
&lt;P&gt;This works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call execute('proc print data=sashelp.class;var');
  call execute('name');
  call execute('sex');
  call execute(';run;');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if you send the exact same set of characters as one string it does not work since there is nothing between the variable names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call execute('proc print data=sashelp.class;varnamesex;run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Breaking the statements into multiple pieces has an impact on how it is parsed by SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Nov 2023 14:24:52 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-11-29T14:24:52Z</dc:date>
    <item>
      <title>Call EXECUTE odditiy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-EXECUTE-odditiy/m-p/905157#M357522</link>
      <description>&lt;P&gt;What would you expect this code to do?&lt;/P&gt;&lt;PRE&gt;data _null_;
  set sashelp.class(obs=4) end=end;
  call execute ('/*');
  call execute ('proc print data=sashelp.class;');
  call execute ('where name='||quote(trim(name))||';');
  call execute ('run;');
  call execute ('*/;');
run;&lt;/PRE&gt;&lt;P&gt;Would you expect the &lt;CODE&gt;proc print&lt;/CODE&gt;s to occur?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 13:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-EXECUTE-odditiy/m-p/905157#M357522</guid>
      <dc:creator>RichardAD</dc:creator>
      <dc:date>2023-11-29T13:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Call EXECUTE odditiy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-EXECUTE-odditiy/m-p/905165#M357524</link>
      <description>&lt;P&gt;No idea.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why would you attempt to send block comments to CALL EXECUTE()?&amp;nbsp; And if you did why in multiple function calls?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Write the code to a file if the goal is to produce a human readable code file.&amp;nbsp; Then the block comments will work as expected when the file is sourced using %INCLUDE.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 14:19:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-EXECUTE-odditiy/m-p/905165#M357524</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-29T14:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Call EXECUTE odditiy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-EXECUTE-odditiy/m-p/905166#M357525</link>
      <description>&lt;P&gt;This code works to comment out the PROC PRINTs, but I don't think I can explain why this works while your original code doesn't.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set sashelp.class(obs=4) end=end;
  call execute ('/%str(*)');
  call execute ('proc print data=sashelp.class;');
  call execute ('where name='||quote(trim(name))||';');
  call execute ('run;');
  call execute ('*/');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Nov 2023 14:23:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-EXECUTE-odditiy/m-p/905166#M357525</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-29T14:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: Call EXECUTE odditiy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-EXECUTE-odditiy/m-p/905168#M357527</link>
      <description>&lt;P&gt;Here is another one.&lt;/P&gt;
&lt;P&gt;This works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call execute('proc print data=sashelp.class;var');
  call execute('name');
  call execute('sex');
  call execute(';run;');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if you send the exact same set of characters as one string it does not work since there is nothing between the variable names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call execute('proc print data=sashelp.class;varnamesex;run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Breaking the statements into multiple pieces has an impact on how it is parsed by SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 14:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-EXECUTE-odditiy/m-p/905168#M357527</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-29T14:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Call EXECUTE odditiy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-EXECUTE-odditiy/m-p/905181#M357531</link>
      <description>&lt;P&gt;call execute's doc says: "Resolves the argument, and issues the resolved valuefor execution at the next step boundary."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so there is fair chance "something" is done with the text.&lt;/P&gt;
&lt;P&gt;It looks a bit like all open comments are automatically "closed" at the end of the call, look at this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set sashelp.class(obs=5);
run;

data _null_;
  set sashelp.class(obs=1) end=end;

  call execute ('proc print /* data=sashelp.class; */ /* data _null_; set sashelp.class;');
  call execute (';where name='||quote(trim(name))||';'); /* semicolon added at the beginning of the line*/
  call execute ('run;');
  call execute ('*/;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;log says:&lt;/P&gt;
&lt;PRE&gt;1    data test;
2      set sashelp.class(obs=5);
3    run;

NOTE: There were 5 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.TEST has 5 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


4
5    data _null_;
6      set sashelp.class(obs=1) end=end;
7
8      call execute ('proc print /* data=sashelp.class; */ /* data _null_; set sashelp.class;');
9      call execute (';where name='||quote(trim(name))||';');
10     call execute ('run;');
11     call execute ('*/;');
12   run;

NOTE: There were 1 observations read from the data set SASHELP.CLASS.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: CALL EXECUTE generated line.
1   + proc print
2   + ;where name="Alfred";
3   + run;

NOTE: There were 1 observations read from the data set WORK.TEST.
      WHERE name='Alfred';
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


4   + */;
&lt;/PRE&gt;
&lt;P&gt;Here is another example that something is happening "at the end of call"&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set sashelp.class(obs=1) end=end;
  call execute ('%nrstr(');
  call execute ('/*');
  call execute ('proc print data=sashelp.class;');
  call execute ('where name='||quote(trim(name))||';');
  call execute ('run;');
  call execute ('*/;');
  call execute (')');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log shows 2 errors:&lt;/P&gt;
&lt;PRE&gt;1    data _null_;
2      set sashelp.class(obs=1) end=end;
3      call execute ('%nrstr(');
4      call execute ('/*');
5      call execute ('proc print data=sashelp.class;');
6      call execute ('where name='||quote(trim(name))||';');
7      call execute ('run;');
8      call execute ('*/;');
9      call execute (')');
10   run;

ERROR: Expected close parenthesis after macro function invocation not found.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 1 observations read from the data set SASHELP.CLASS.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: CALL EXECUTE generated line.
2   + proc print data=sashelp.class;
3   + where name="Alfred";
4   + run;

NOTE: There were 1 observations read from the data set SASHELP.CLASS.
      WHERE name='Alfred';
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


5   + */;
NOTE: Line generated by the CALL EXECUTE routine.
6   + )
      -
      180

ERROR 180-322: Statement is not valid or it is used out of proper order.
&lt;/PRE&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S. Agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;'s suggestion to do it in one call:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set sashelp.class(obs=1) end=end;
  call execute ( " "
             !! "/*"
             !! 'proc print data=sashelp.class;'
             !! 'where name='||quote(trim(name))||';'
             !! 'run;'
             !! '*/'
             );
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;such setup allows even for "cinditional" commenting out:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let commentOut=1;
data _null_;
  set sashelp.class(obs=1) end=end;
  call execute ( " "
             !! ifc(symgetn('commentOut'), "/*", " ")
             !! 'proc print data=sashelp.class;'
             !! 'where name='||quote(trim(name))||';'
             !! 'run;'
             !! '*/'
             );
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Nov 2023 15:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-EXECUTE-odditiy/m-p/905181#M357531</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-11-29T15:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Call EXECUTE odditiy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-EXECUTE-odditiy/m-p/905224#M357551</link>
      <description>&lt;P&gt;Interesting.&amp;nbsp; If you have Display Manager (PC SAS), you can submit code one statement at time, in some settings one token at a time.&amp;nbsp; And sometimes it's instructive.&amp;nbsp; This doesn't work with EG or I suspect Studio, because they're essentially doing batch submits and add wrapper code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Forget CALL EXECUTE for a moment, if you code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
proc print data=sashelp.class;
run ;
*/
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And run the code one line at a time (so 4 code submissions), it will run the PROC PRINT step.&amp;nbsp; And the last */ will not create an un-closed * comment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My log looks like:&lt;/P&gt;
&lt;PRE&gt;1    /*

2    proc print data=sashelp.class;
3    run ;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.

4    */
&lt;/PRE&gt;
&lt;P&gt;So even without CALL EXECUTE, if you submit a just a /* token, SAS is automatically closing it.&amp;nbsp; And if you submit just */, SAS is also automatically closing that * comment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know if there is a documented rule about SAS automatically closing a comment if you submit an un-closed comment.&amp;nbsp; But it seems to be part of the SAS language, not CALL EXECUTE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 17:54:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-EXECUTE-odditiy/m-p/905224#M357551</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-11-29T17:54:59Z</dc:date>
    </item>
  </channel>
</rss>

