<?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 can I concatenate two variables in a Macro with an underscore between them in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-concatenate-two-variables-in-a-Macro-with-an/m-p/87022#M257091</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 14pt;"&gt;&amp;amp;vara._&amp;amp;varb&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You do not need an operator to combine strings generated by macro code.&amp;nbsp; But you do need something to help the parser distinguish between whether you want the value of macro variable VARA or one named VARA_ .&amp;nbsp; So you need to add a period before the _.&amp;nbsp;&amp;nbsp; Now if you really do need to have a period immediately after an expanded macro variable then you will have to type two as the first will be interpreted as ending the macro variable reference.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 26 Jan 2013 19:21:10 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2013-01-26T19:21:10Z</dc:date>
    <item>
      <title>How can I concatenate two variables in a Macro with an underscore between them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-concatenate-two-variables-in-a-Macro-with-an/m-p/87020#M257089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suppose I have the following macro&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%MACRO MacroA(varA, varB);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to create a new dataset that should be named &lt;EM&gt;&lt;STRONG&gt;varA_varB&lt;/STRONG&gt;&lt;/EM&gt;. For example, if varA is &lt;EM&gt;hello &lt;/EM&gt;and varB is &lt;EM&gt;world&lt;/EM&gt;, the datasource would be &lt;EM&gt;hello_world&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried &lt;SPAN style="font-family: 'courier new', courier; color: #0000ff;"&gt;&lt;STRONG&gt;&amp;amp;varA + "_" &amp;amp;varB&lt;/STRONG&gt;&lt;/SPAN&gt; in my macro code, but SAS doesn't like that. How can I achieve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;P.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Jan 2013 17:19:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-concatenate-two-variables-in-a-Macro-with-an/m-p/87020#M257089</guid>
      <dc:creator>pmdci</dc:creator>
      <dc:date>2013-01-26T17:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: How can I concatenate two variables in a Macro with an underscore between them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-concatenate-two-variables-in-a-Macro-with-an/m-p/87021#M257090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data class1 class2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%macro macroa(vara,varb);&lt;/P&gt;&lt;P&gt;data &amp;amp;vara._&amp;amp;varb;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set &amp;amp;vara &amp;amp;varb;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macroa(class1,class2)&lt;/P&gt;&lt;P&gt;proc print data=&amp;amp;syslast;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Jan 2013 17:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-concatenate-two-variables-in-a-Macro-with-an/m-p/87021#M257090</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2013-01-26T17:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I concatenate two variables in a Macro with an underscore between them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-concatenate-two-variables-in-a-Macro-with-an/m-p/87022#M257091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 14pt;"&gt;&amp;amp;vara._&amp;amp;varb&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You do not need an operator to combine strings generated by macro code.&amp;nbsp; But you do need something to help the parser distinguish between whether you want the value of macro variable VARA or one named VARA_ .&amp;nbsp; So you need to add a period before the _.&amp;nbsp;&amp;nbsp; Now if you really do need to have a period immediately after an expanded macro variable then you will have to type two as the first will be interpreted as ending the macro variable reference.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Jan 2013 19:21:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-concatenate-two-variables-in-a-Macro-with-an/m-p/87022#M257091</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-01-26T19:21:10Z</dc:date>
    </item>
  </channel>
</rss>

