<?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 Concatenate strings in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-strings/m-p/41061#M8409</link>
    <description>Hi there,&lt;BR /&gt;
I'm not sure if this is the right place for this post, if not I'm sorry!&lt;BR /&gt;
I have the following problem:&lt;BR /&gt;
My data looks like that (simplified):&lt;BR /&gt;
Text       group&lt;BR /&gt;
text1         1&lt;BR /&gt;
text2         1&lt;BR /&gt;
text3         1&lt;BR /&gt;
text4         1&lt;BR /&gt;
text1         2&lt;BR /&gt;
text2         2&lt;BR /&gt;
text1         3&lt;BR /&gt;
text2         3&lt;BR /&gt;
text3         3&lt;BR /&gt;
&lt;BR /&gt;
Now I want to concatenate the strings in 'Text' for each group so that the data looks like that:&lt;BR /&gt;
&lt;BR /&gt;
Text                                  group&lt;BR /&gt;
text1_text2_text3_text4         1&lt;BR /&gt;
text1_text2                           2&lt;BR /&gt;
text1_text2_text3                  3&lt;BR /&gt;
&lt;BR /&gt;
Can anyone help me with this? Another question here is the maximal length of a string variable.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
&lt;BR /&gt;
Valentin</description>
    <pubDate>Wed, 30 Mar 2011 17:24:31 GMT</pubDate>
    <dc:creator>Valentin_HU</dc:creator>
    <dc:date>2011-03-30T17:24:31Z</dc:date>
    <item>
      <title>Concatenate strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-strings/m-p/41061#M8409</link>
      <description>Hi there,&lt;BR /&gt;
I'm not sure if this is the right place for this post, if not I'm sorry!&lt;BR /&gt;
I have the following problem:&lt;BR /&gt;
My data looks like that (simplified):&lt;BR /&gt;
Text       group&lt;BR /&gt;
text1         1&lt;BR /&gt;
text2         1&lt;BR /&gt;
text3         1&lt;BR /&gt;
text4         1&lt;BR /&gt;
text1         2&lt;BR /&gt;
text2         2&lt;BR /&gt;
text1         3&lt;BR /&gt;
text2         3&lt;BR /&gt;
text3         3&lt;BR /&gt;
&lt;BR /&gt;
Now I want to concatenate the strings in 'Text' for each group so that the data looks like that:&lt;BR /&gt;
&lt;BR /&gt;
Text                                  group&lt;BR /&gt;
text1_text2_text3_text4         1&lt;BR /&gt;
text1_text2                           2&lt;BR /&gt;
text1_text2_text3                  3&lt;BR /&gt;
&lt;BR /&gt;
Can anyone help me with this? Another question here is the maximal length of a string variable.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
&lt;BR /&gt;
Valentin</description>
      <pubDate>Wed, 30 Mar 2011 17:24:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-strings/m-p/41061#M8409</guid>
      <dc:creator>Valentin_HU</dc:creator>
      <dc:date>2011-03-30T17:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-strings/m-p/41062#M8410</link>
      <description>Hello Vvalentin_HU,&lt;BR /&gt;
&lt;BR /&gt;
This is a solution:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data i;&lt;BR /&gt;
  input Text $ group;&lt;BR /&gt;
datalines;&lt;BR /&gt;
text1 1&lt;BR /&gt;
text2 1&lt;BR /&gt;
text3 1&lt;BR /&gt;
text4 1&lt;BR /&gt;
text1 2&lt;BR /&gt;
text2 2&lt;BR /&gt;
text1 3&lt;BR /&gt;
text2 3&lt;BR /&gt;
text3 3&lt;BR /&gt;
run;&lt;BR /&gt;
data r;&lt;BR /&gt;
  retain t;&lt;BR /&gt;
  length t $100;&lt;BR /&gt;
  set i;&lt;BR /&gt;
  if First.group then t="";&lt;BR /&gt;
  t=CATX('_',t,text);  &lt;BR /&gt;
  if Last.group then output;&lt;BR /&gt;
  by group;&lt;BR /&gt;
  keep t group;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Wed, 30 Mar 2011 17:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-strings/m-p/41062#M8410</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-03-30T17:41:30Z</dc:date>
    </item>
  </channel>
</rss>

