<?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 Can a macro be used to concatenate variables into a new variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-a-macro-be-used-to-concatenate-variables-into-a-new-variable/m-p/36886#M7268</link>
    <description>Hi- I'm wondering if a macro can be written that concatenates comments into one comment field.  For example, the code below concatenates 8 comment fields.  However, the maximum number of comments can change each time it is run, so I want it to be flexible so that if the maximum number of comments changes from 8 to 10, it will concatenate all 10 comment fields.  Any help would be greatly appreciated!&lt;BR /&gt;
&lt;BR /&gt;
data dat2 (keep=compyr fnlcomment);&lt;BR /&gt;
  set wide;&lt;BR /&gt;
fnlcomment=cmt1||' '||cmt2||' '||cmt3||' '||cmt4||' '||cmt5||' '||cmt6||' '||cmt7||' '||cmt8;&lt;BR /&gt;
run;</description>
    <pubDate>Wed, 27 May 2009 01:18:23 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-05-27T01:18:23Z</dc:date>
    <item>
      <title>Can a macro be used to concatenate variables into a new variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-a-macro-be-used-to-concatenate-variables-into-a-new-variable/m-p/36886#M7268</link>
      <description>Hi- I'm wondering if a macro can be written that concatenates comments into one comment field.  For example, the code below concatenates 8 comment fields.  However, the maximum number of comments can change each time it is run, so I want it to be flexible so that if the maximum number of comments changes from 8 to 10, it will concatenate all 10 comment fields.  Any help would be greatly appreciated!&lt;BR /&gt;
&lt;BR /&gt;
data dat2 (keep=compyr fnlcomment);&lt;BR /&gt;
  set wide;&lt;BR /&gt;
fnlcomment=cmt1||' '||cmt2||' '||cmt3||' '||cmt4||' '||cmt5||' '||cmt6||' '||cmt7||' '||cmt8;&lt;BR /&gt;
run;</description>
      <pubDate>Wed, 27 May 2009 01:18:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-a-macro-be-used-to-concatenate-variables-into-a-new-variable/m-p/36886#M7268</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-27T01:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: Can a macro be used to concatenate variables into a new variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-a-macro-be-used-to-concatenate-variables-into-a-new-variable/m-p/36887#M7269</link>
      <description>The code below demonstrates one string concatenation technique when the variables have a stem value:&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
retain cmnt1-cmnt5 'xyz';&lt;BR /&gt;
length fullcmt $100;&lt;BR /&gt;
fullcmt = catx(' ',of cmnt: );&lt;BR /&gt;
putlog _all_;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Another approach when a stem variable prefix is not available, consider using an ARRAY and a DO I=1 TO DIM(&lt;ARRAYNAME&gt;); END; to concatenate each individual variable, referenced as an array component.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;/ARRAYNAME&gt;</description>
      <pubDate>Wed, 27 May 2009 01:48:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-a-macro-be-used-to-concatenate-variables-into-a-new-variable/m-p/36887#M7269</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-05-27T01:48:17Z</dc:date>
    </item>
  </channel>
</rss>

