<?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 macro execution when parameter contains semicolon in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882816#M348813</link>
    <description>&lt;P&gt;You probably need to use %Qsysfunc to add macro quoting to the result.&lt;/P&gt;
&lt;PRE&gt;55   %let x=%sysfunc(dequote('aa;bb'));
NOTE: Line generated by the macro function "SYSFUNC".
1    aa;bb
        --
        180
ERROR 180-322: Statement is not valid or it is used out of proper order.

56   %put &amp;amp;=x;
X=aa
57   %let x=%qsysfunc(dequote('aa;bb'));
58   %put &amp;amp;=x;
X=aa;bb
&lt;/PRE&gt;</description>
    <pubDate>Wed, 28 Jun 2023 15:35:03 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-06-28T15:35:03Z</dc:date>
    <item>
      <title>Error macro execution when parameter contains semicolon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882762#M348773</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am struggling to make a macro call that includes semicolons inside the parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA _NULL_;
SET WORK.HAVE END=eof ;
call execute('%MyMacro('||list_coordinates||')');
RUN;&lt;/PRE&gt;&lt;P&gt;My 'list_coordinates' parameter is something like 51.95179749,7.99066114;51.17936325,6.74318409;51.33995819,4.31496429.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting the following error each time that found a semicolon:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Statement is not valid or it is used out of proper order&lt;/PRE&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 10:34:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882762#M348773</guid>
      <dc:creator>MM88</dc:creator>
      <dc:date>2023-06-28T10:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Error macro execution when parameter contains semicolon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882764#M348775</link>
      <description>&lt;P&gt;My personal advice: change the macro so that it accepts less critical delimiters, e.g. pipes (|).&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 10:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882764#M348775</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-06-28T10:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: Error macro execution when parameter contains semicolon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882767#M348776</link>
      <description>Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;Semicolon is not my delimiter choice.&lt;BR /&gt;&lt;BR /&gt;Inside the macro I call a webservice that receive the coordinates list separated by semicolons.&lt;BR /&gt;&lt;BR /&gt;Any advice?</description>
      <pubDate>Wed, 28 Jun 2023 11:01:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882767#M348776</guid>
      <dc:creator>MM88</dc:creator>
      <dc:date>2023-06-28T11:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Error macro execution when parameter contains semicolon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882771#M348777</link>
      <description>&lt;P&gt;Then replace the uncritical delimiter in the macro, right where you make the web call. Use the TRANSLATE function for this.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 11:11:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882771#M348777</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-06-28T11:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Error macro execution when parameter contains semicolon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882772#M348778</link>
      <description>&lt;P&gt;Can you make a full example that replicates the problem?&amp;nbsp; I tried this simple test:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro mymacro(x) ;
  %put &amp;amp;x ;
%mend ;

data have ;
  list_coordinates="51.95179749 7.99066114;51.17936325 6.74318409;51.33995819 4.31496429" ;
run ;

DATA _NULL_;
  SET WORK.HAVE END=eof ;
  call execute('%MyMacro('||list_coordinates||')');
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and did not get the error message you're getting.&amp;nbsp; My guess is the error is coming from some code inside your macro.&amp;nbsp; You may need to add macro quoting.&amp;nbsp; (Note I removed the commas from list_coordinates, because they cause a different error message).&amp;nbsp; If you could post full example code, and include the log, that would be helpful.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 11:33:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882772#M348778</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-06-28T11:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Error macro execution when parameter contains semicolon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882774#M348779</link>
      <description>&lt;P&gt;The simplest thing it to modify the macro to accept quotes around the parameter value.&amp;nbsp; It can always use %SYSFUNC() to call DEQUOTE() if they need to be removed.&lt;/P&gt;
&lt;PRE&gt;43   DATA _NULL_;
44     SET HAVE END=eof ;
45     call execute(cats('%nrstr(%MyMacro)(',quote(trim(list_coordinates),"'"),')'));
46   RUN;

NOTE: There were 1 observations read from the data set WORK.HAVE.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


NOTE: CALL EXECUTE generated line.
1   + %MyMacro('51.95179749,7.99066114;51.17936325,6.74318409;51.33995819,4.31496429')
X='51.95179749,7.99066114;51.17936325,6.74318409;51.33995819,4.31496429'
&lt;/PRE&gt;
&lt;P&gt;But you could also add macro quoting in the generated call.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;47   DATA _NULL_;
48     SET HAVE END=eof ;
49     call execute(cats('%nrstr(%MyMacro(%nrstr(',list_coordinates,')))'));
50   RUN;

NOTE: There were 1 observations read from the data set WORK.HAVE.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: CALL EXECUTE generated line.
1   + %MyMacro(%nrstr(51.95179749,7.99066114;51.17936325,6.74318409;51.33995819,4.31496429))
X=51.95179749,7.99066114;51.17936325,6.74318409;51.33995819,4.31496429

&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jun 2023 11:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882774#M348779</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-28T11:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Error macro execution when parameter contains semicolon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882815#M348812</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;Thanks for the suggestions. I made it work using&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;first suggestion calling the macro parameter between quotes.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA _NULL_;
     SET HAVE END=eof ;
     call execute(cats('%nrstr(%MyMacro)(',quote(trim(list_coordinates),"'"),')'));
RUN;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Then I 'dequote' the parameter inside my macro and use the new one.&lt;/P&gt;&lt;PRE&gt;%macro MyMacro(list_coordinates);
    %let new_coordinates_list = %sysfunc(dequote(&amp;amp;list_coordinates));
    /*Call my webservice using new_coordinates_list*/
%mend MyMacro;&lt;/PRE&gt;&lt;P&gt;Thanks for your time.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 15:31:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882815#M348812</guid>
      <dc:creator>MM88</dc:creator>
      <dc:date>2023-06-28T15:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Error macro execution when parameter contains semicolon</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882816#M348813</link>
      <description>&lt;P&gt;You probably need to use %Qsysfunc to add macro quoting to the result.&lt;/P&gt;
&lt;PRE&gt;55   %let x=%sysfunc(dequote('aa;bb'));
NOTE: Line generated by the macro function "SYSFUNC".
1    aa;bb
        --
        180
ERROR 180-322: Statement is not valid or it is used out of proper order.

56   %put &amp;amp;=x;
X=aa
57   %let x=%qsysfunc(dequote('aa;bb'));
58   %put &amp;amp;=x;
X=aa;bb
&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jun 2023 15:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-macro-execution-when-parameter-contains-semicolon/m-p/882816#M348813</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-28T15:35:03Z</dc:date>
    </item>
  </channel>
</rss>

