<?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: concatenate two macro variables with &amp;quot;/&amp;quot; between them in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/concatenate-two-macro-variables-with-quot-quot-between-them/m-p/926447#M364570</link>
    <description>&lt;P&gt;You are overcomplicating things.&amp;nbsp; This would be the usual way to concatenate strings in macro language:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let customer_branch=&amp;amp;customer_ID./&amp;amp;branch_Id.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Simple.&amp;nbsp; Macro language does not perform math in a %let statement&amp;nbsp; However, if you use the variable later, macro language may try to perform math.&amp;nbsp; For example, this statement would have the potential to cause trouble:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if 9872622/987 = &amp;amp;customer_branch %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;%IF/%THEN statements do try to perform math.&amp;nbsp; While there are a few ways to suppress this, an easy way would be to add double quotes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if "9872622/987" = "&amp;amp;customer_branch" %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The quotes become part of the comparison.&lt;/P&gt;</description>
    <pubDate>Tue, 30 Apr 2024 12:04:21 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2024-04-30T12:04:21Z</dc:date>
    <item>
      <title>concatenate two macro variables with "/" between them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-two-macro-variables-with-quot-quot-between-them/m-p/926446#M364569</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to concatenate two macro variables with "/" between them.&lt;/P&gt;
&lt;P&gt;I get error 49&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let customer_ID=9872622;
%let branch_Id=987;
%let customer_branch=%sysfunc(cat(&amp;amp;customer_ID.,"/",&amp;amp;branch_Id.));/***9872622/987*****/
%put &amp;amp;customer_branch;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 11:23:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-two-macro-variables-with-quot-quot-between-them/m-p/926446#M364569</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-04-30T11:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate two macro variables with "/" between them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-two-macro-variables-with-quot-quot-between-them/m-p/926447#M364570</link>
      <description>&lt;P&gt;You are overcomplicating things.&amp;nbsp; This would be the usual way to concatenate strings in macro language:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let customer_branch=&amp;amp;customer_ID./&amp;amp;branch_Id.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Simple.&amp;nbsp; Macro language does not perform math in a %let statement&amp;nbsp; However, if you use the variable later, macro language may try to perform math.&amp;nbsp; For example, this statement would have the potential to cause trouble:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if 9872622/987 = &amp;amp;customer_branch %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;%IF/%THEN statements do try to perform math.&amp;nbsp; While there are a few ways to suppress this, an easy way would be to add double quotes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if "9872622/987" = "&amp;amp;customer_branch" %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The quotes become part of the comparison.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 12:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-two-macro-variables-with-quot-quot-between-them/m-p/926447#M364570</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2024-04-30T12:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate two macro variables with "/" between them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-two-macro-variables-with-quot-quot-between-them/m-p/926453#M364572</link>
      <description>&lt;P&gt;No quotes used inside %SYSFUNC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let customer_branch=%sysfunc(cat(&amp;amp;customer_ID.,/,&amp;amp;branch_Id.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But really&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;has the better advice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it mandatory to use a slash here (which sometimes will be interpreted as division)? Couldn't some other character, which isn't also a mathematical operator, such as underscore, work here? Do you even need a character like slash or underscore, could you just append customer_id and branch_id without any character between the two? All of this would make your programming simpler.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 13:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-two-macro-variables-with-quot-quot-between-them/m-p/926453#M364572</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-30T13:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: concatenate two macro variables with "/" between them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/concatenate-two-macro-variables-with-quot-quot-between-them/m-p/926509#M364598</link>
      <description>&lt;P&gt;I have never found any use for the CAT() series of functions in MACRO code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First thing is they are just not needed.&amp;nbsp; To place values next to each other all you have to do is place the values next to each other.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let customer_branch=&amp;amp;customer_ID./&amp;amp;branch_Id.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Second thing is that the CAT...() functions are some the most problematic for the %SYSFUNC() macro function.&amp;nbsp; They can take either character or numeric values for all of their arguments.&amp;nbsp; So poor %SYSFUNC() has to try and GUESS whether it should tell CAT... that the values it is send are numbers or strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only one of them that might be useful to have in macro code is CATX() since replicating the inclusion of the delimiter only when there are non-empty values would be difficult without macro logic.&amp;nbsp; So here is a SAS macro that can do for macro code what CATX() does for SAS code.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/sasutils/macros/blob/master/catx.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/catx.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 18:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/concatenate-two-macro-variables-with-quot-quot-between-them/m-p/926509#M364598</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-30T18:16:04Z</dc:date>
    </item>
  </channel>
</rss>

