<?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: How to use brackets in macro parameters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-brackets-in-macro-parameters/m-p/955340#M373112</link>
    <description>&lt;P&gt;Assuming by "brackets" you mean normal parentheses then they are actually HELPFUL when passing values into macro parameters because they allow you to include commas in the values without the macro processor interpreting the commas as delimiters between parameter values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your code works fine (once you fix the typo in the macro variable name and adjust the LENGTH of the character values stored in the second array).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array a[2] _temporary_ &amp;amp;probs;
array b[2] $255 _temporary_ &amp;amp;labels;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Another useful thing to understand is that SAS does NOT need the commas in those lists of values, spaces work fine.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array a[2] _temporary_ (0.5 0.5);
array b[2] $200 _temporary_ ('train' 'validation');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The same thing applies to lists of values in other places, like the IN operator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you could remove the parentheses from your macro call and instead have the macro insert them.&amp;nbsp; Then call the macro using spaces between the values in the lists.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro data_split(dataset,probs,labels);
data split_data;
  array a[2] _temporary_ (&amp;amp;probs);
  array b[2] $255 _temporary_ (&amp;amp;labels);
  set &amp;amp;dataset;
  * some code that actually uses A and B ;
run;
%mend;
%data_split(work.combine_data,probs=0.5 0.5,labels="a" "b")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;You can include the parentheses in the macro call still since the ARRAY statement does not mind if you add extra nested pairs.&amp;nbsp; Example:&lt;/P&gt;
&lt;PRE&gt;67   data test;
68     array x[4] ((1 2) (3 4));
69     put _all_;
70   run;

x1=1 x2=2 x3=3 x4=4 _ERROR_=0 _N_=1
&lt;/PRE&gt;</description>
    <pubDate>Tue, 07 Jan 2025 18:24:13 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2025-01-07T18:24:13Z</dc:date>
    <item>
      <title>How to use brackets in macro parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-brackets-in-macro-parameters/m-p/955336#M373110</link>
      <description>&lt;P&gt;Hi The original code is below and I tried to make these code to a macro:&lt;/P&gt;&lt;P&gt;data work.split_data;&lt;BR /&gt;array a[2] _temporary_ (0.5,0.5);&lt;BR /&gt;array b[2] $ _temporary_ ('train','validation')&lt;/P&gt;&lt;P&gt;;&lt;BR /&gt;set combine_data;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The macro I made is below and I keep getting errors. Can anyone help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro data_split(dataset,probs,labels);&lt;BR /&gt;data work.split_data;&lt;BR /&gt;array a[2] _temporary_ &amp;amp;prob;&lt;BR /&gt;array b[2] $ _temporary_ &amp;amp;labels;&lt;BR /&gt;set &amp;amp;dataset;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%data_split(work.combine_data,probs=(0.5, 0.5),labels=("a", "b"));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2025 16:54:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-brackets-in-macro-parameters/m-p/955336#M373110</guid>
      <dc:creator>Li2024</dc:creator>
      <dc:date>2025-01-07T16:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to use brackets in macro parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-brackets-in-macro-parameters/m-p/955338#M373111</link>
      <description>&lt;P&gt;When you're asking a question about an error message, please include the error message in your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming you get the error I get:&lt;/P&gt;
&lt;PRE&gt;1       data work.split_data; array a[2] _temporary_ &amp;amp;prob; array b[2] $ _temporary_ &amp;amp;labels; set &amp;amp;dataset; run;
                                                     -
                                                     22
                                                     200
WARNING: Apparent symbolic reference PROB not resolved.

ERROR 22-322: Syntax error, expecting one of the following: (, ;.

ERROR 200-322: The symbol is not recognized and will be ignored.
&lt;/PRE&gt;
&lt;P&gt;Then the problem is a typo in your code.&amp;nbsp; Your array statement references a macro variable named PROB but it should reference PROBS:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array a[2] _temporary_ &amp;amp;prob;  *Missing an S on &amp;amp;probS;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2025 17:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-brackets-in-macro-parameters/m-p/955338#M373111</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2025-01-07T17:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to use brackets in macro parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-brackets-in-macro-parameters/m-p/955340#M373112</link>
      <description>&lt;P&gt;Assuming by "brackets" you mean normal parentheses then they are actually HELPFUL when passing values into macro parameters because they allow you to include commas in the values without the macro processor interpreting the commas as delimiters between parameter values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your code works fine (once you fix the typo in the macro variable name and adjust the LENGTH of the character values stored in the second array).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array a[2] _temporary_ &amp;amp;probs;
array b[2] $255 _temporary_ &amp;amp;labels;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Another useful thing to understand is that SAS does NOT need the commas in those lists of values, spaces work fine.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array a[2] _temporary_ (0.5 0.5);
array b[2] $200 _temporary_ ('train' 'validation');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The same thing applies to lists of values in other places, like the IN operator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you could remove the parentheses from your macro call and instead have the macro insert them.&amp;nbsp; Then call the macro using spaces between the values in the lists.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro data_split(dataset,probs,labels);
data split_data;
  array a[2] _temporary_ (&amp;amp;probs);
  array b[2] $255 _temporary_ (&amp;amp;labels);
  set &amp;amp;dataset;
  * some code that actually uses A and B ;
run;
%mend;
%data_split(work.combine_data,probs=0.5 0.5,labels="a" "b")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;You can include the parentheses in the macro call still since the ARRAY statement does not mind if you add extra nested pairs.&amp;nbsp; Example:&lt;/P&gt;
&lt;PRE&gt;67   data test;
68     array x[4] ((1 2) (3 4));
69     put _all_;
70   run;

x1=1 x2=2 x3=3 x4=4 _ERROR_=0 _N_=1
&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jan 2025 18:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-brackets-in-macro-parameters/m-p/955340#M373112</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-07T18:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to use brackets in macro parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-brackets-in-macro-parameters/m-p/955351#M373116</link>
      <description>&lt;P&gt;Thanks, I made a really stupid mistake. ....&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2025 18:18:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-brackets-in-macro-parameters/m-p/955351#M373116</guid>
      <dc:creator>Li2024</dc:creator>
      <dc:date>2025-01-07T18:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use brackets in macro parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-brackets-in-macro-parameters/m-p/955352#M373117</link>
      <description>&lt;P&gt;Thanks, I made really stupid mistake.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2025 18:19:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-brackets-in-macro-parameters/m-p/955352#M373117</guid>
      <dc:creator>Li2024</dc:creator>
      <dc:date>2025-01-07T18:19:16Z</dc:date>
    </item>
  </channel>
</rss>

