<?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: Combining the same variable on different records into a single variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111562#M23108</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmmm... tried to update my solution but it's not being accepted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I reread the problem, and it seems I have the wrong SET statement.&amp;nbsp; Since you have only one source of data, the SET statement should read:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking at the trouble you had with Linlin's solution, it may need a longer length for NEWLINE.&amp;nbsp; And the RETAIN statement has an extra blank between NEW and LINE.&amp;nbsp; But the idea is sound.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 May 2012 14:56:42 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2012-05-11T14:56:42Z</dc:date>
    <item>
      <title>Combining the same variable on different records into a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111557#M23103</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a requirement where I have to combine the data present in the same variable on different datasets into a single variable. The format of the variables is character. The records are linked by a particular id. So for a particular id if we have 5 rows and each of the five rows contain a char variable called LINe , then we need to produce one record which contains the two variables id and LINE. Here LINE is a combination of the LINE variable from the five records which are linked by the id. Given below is an example of the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;100&amp;nbsp; abcdefghijkollldsdksjd&lt;/P&gt;&lt;P&gt;100 djsjdklsjdksdlsldklskdsld;sk;dks;&lt;/P&gt;&lt;P&gt;100 djskdjsldjlsdjlsdjlsdljskdjskdjskdioeioeoeoe&lt;/P&gt;&lt;P&gt;100 jksldksldklsldklsdksldksldklskdls&lt;/P&gt;&lt;P&gt;100 djsldksldksldklsdk;d;;adskldkasldklsdksdkl;skdsk&lt;/P&gt;&lt;P&gt;200 djksldklskdlskdls\&lt;/P&gt;&lt;P&gt;200 uuuuuuuuuuuuuuuuuu&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output required&lt;/P&gt;&lt;P&gt;100 abcdefghijkollldsdksjddjsjdklsjdksdlsldklskdsld;sk;dks;djskdjsldjlsdjlsdjlsdljskdjskdjskdioeioeoeoejksldksldklsldklsdksldksldklskdlsdjsldksldksldklsdk;d;;adskldkasldklsdksdkl;skdsk&lt;/P&gt;&lt;P&gt;200 djksldklskdlskdls\uuuuuuuuuuuuuuuuuu&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 10:14:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111557#M23103</guid>
      <dc:creator>kdm</dc:creator>
      <dc:date>2012-05-11T10:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: Combining the same variable on different records into a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111558#M23104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 14pt;"&gt;/* this one doesn't work */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;try:&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input id line$ 50.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;100&amp;nbsp; abcdefghijkollldsdksjd&lt;/P&gt;&lt;P&gt;100 djsjdklsjdksdlsldklskdsld&lt;/P&gt;&lt;P&gt;100 djskdjsldjlsdjlsdjlsdljskdjskdjskdioeioeoeoe&lt;/P&gt;&lt;P&gt;100 jksldksldklsldklsdksldksldklskdls&lt;/P&gt;&lt;P&gt;100 djsldksldksldklsdkdadskldkasldklsdksdklskdsk&lt;/P&gt;&lt;P&gt;200 djksldklskdlskdls&lt;/P&gt;&lt;P&gt;200 uuuuuuuuuuuuuuuuuu&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;length newline $250;&lt;/P&gt;&lt;P&gt;retain new line;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by id notsorted;&lt;/P&gt;&lt;P&gt;newline=cats(newline,line);&lt;/P&gt;&lt;P&gt;if last.id then output;&lt;/P&gt;&lt;P&gt;call missing(newline);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Linlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 11:07:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111558#M23104</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-05-11T11:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Combining the same variable on different records into a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111559#M23105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you need firstly merge them all into one table ,then concatenate them all together.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt; merge a1(rename=(line=line_1)) a2(rename=(line=line_2)) a3(rename=(line=line_3));&lt;/P&gt;&lt;P&gt; by id;&lt;/P&gt;&lt;P&gt;length line $2000 ;&lt;/P&gt;&lt;P&gt;line=cats(of line_: );&lt;/P&gt;&lt;P&gt;drop line_:&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is a good start.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 11:43:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111559#M23105</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-05-11T11:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Combining the same variable on different records into a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111560#M23106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another variation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; length bigline $ 2000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; retain bigline;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have1 have2 have3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if first.id then bigline=line;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else bigline = trim(bigline) || line;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if last.id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that the CATS function could, in rare cases, produce a slightly different result.&amp;nbsp; If one of your LINE values contains leading blanks, they would be removed.&amp;nbsp; Perhaps that's even desirable, but that is a choice you should be aware of.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 14:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111560#M23106</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-05-11T14:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Combining the same variable on different records into a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111561#M23107</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried what LiniLin suggested, but newline gets a length of the first line and hence the rest of the items get truncated or are not concatenated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Kurian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 14:11:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111561#M23107</guid>
      <dc:creator>kdm</dc:creator>
      <dc:date>2012-05-11T14:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Combining the same variable on different records into a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111562#M23108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmmm... tried to update my solution but it's not being accepted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I reread the problem, and it seems I have the wrong SET statement.&amp;nbsp; Since you have only one source of data, the SET statement should read:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking at the trouble you had with Linlin's solution, it may need a longer length for NEWLINE.&amp;nbsp; And the RETAIN statement has an extra blank between NEW and LINE.&amp;nbsp; But the idea is sound.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 14:56:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111562#M23108</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-05-11T14:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: Combining the same variable on different records into a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111563#M23109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry.:smileysilly:&lt;/P&gt;&lt;P&gt;try this:&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input id line$ 50.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;100&amp;nbsp; abcdefghijkollldsdksjd&lt;/P&gt;&lt;P&gt;100 djsjdklsjdksdlsldklskdsld&lt;/P&gt;&lt;P&gt;100 djskdjsldjlsdjlsdjlsdljskdjskdjskdioeioeoeoe&lt;/P&gt;&lt;P&gt;100 jksldksldklsldklsdksldksldklskdls&lt;/P&gt;&lt;P&gt;100 djsldksldksldklsdkdadskldkasldklsdksdklskdsk&lt;/P&gt;&lt;P&gt;200 djksldklskdlskdls&lt;/P&gt;&lt;P&gt;200 uuuuuuuuuuuuuuuuuu&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data want(keep=newline);&lt;/P&gt;&lt;P&gt;length newline $250;&lt;/P&gt;&lt;P&gt;retain newline;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by id ;&lt;/P&gt;&lt;P&gt;newline=cats(newline,line);&lt;/P&gt;&lt;P&gt;if last.id then do;output ;&lt;/P&gt;&lt;P&gt;call missing(newline); end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt; Obs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newline&lt;/P&gt;&lt;P&gt; 1&amp;nbsp; abcdefghijkollldsdksjddjsjdklsjdksdlsldklskdslddjskdjsldjlsdjlsdjlsdljskdjskdjs&lt;/P&gt;&lt;P&gt; 2&amp;nbsp; djksldklskdlskdlsuuuuuuuuuuuuuuuuuu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 15:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111563#M23109</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-05-11T15:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Combining the same variable on different records into a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111564#M23110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Astounding,&lt;/P&gt;&lt;P&gt;there are two problems in my first post.&lt;/P&gt;&lt;P&gt;one is the space between "new line";&lt;/P&gt;&lt;P&gt;another is&lt;/P&gt;&lt;P&gt;"if last.id then output;call missing(newline);run;"&lt;/P&gt;&lt;P&gt;it should be&lt;/P&gt;&lt;P&gt;"if last.id then do;output;call missing(newline);end;run;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks - Linlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 15:38:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111564#M23110</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-05-11T15:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: Combining the same variable on different records into a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111565#M23111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... here's another idea (no RETAIN statement, no CAT function)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you'll have to guess at the length of NEWVAR (without that LENGTH statement, NEWVAR's length will be 32K)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data have;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;input id line $50.;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;cards;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;100 abcdefghijkollldsdksjd&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;100 djsjdklsjdksdlsldklskdsld&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;SPAN style="color: #222222; font-size: 15px; text-align: -webkit-auto; background-color: rgba(255, 255, 255, 0.917969);"&gt;100 djskdjsldjlsdjlsdjlsdljskdjskd&lt;/SPAN&gt;&lt;SPAN style="color: #222222; font-size: 15px; text-align: -webkit-auto; background-color: rgba(255, 255, 255, 0.917969);"&gt;jskdioeioeoeoe&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;SPAN style="color: #222222; font-size: 15px; text-align: -webkit-auto; background-color: rgba(255, 255, 255, 0.917969);"&gt;100 jksldksldklsldklsdksldksldklsk&lt;/SPAN&gt;&lt;SPAN style="color: #222222; font-size: 15px; text-align: -webkit-auto; background-color: rgba(255, 255, 255, 0.917969);"&gt;dls&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;SPAN style="color: #222222; font-size: 15px; text-align: -webkit-auto; background-color: rgba(255, 255, 255, 0.917969);"&gt;100 djsldksldksldklsdkdadskldkasld&lt;/SPAN&gt;&lt;SPAN style="color: #222222; font-size: 15px; text-align: -webkit-auto; background-color: rgba(255, 255, 255, 0.917969);"&gt;klsdksdklskdsk&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;200 djksldklskdlskdls&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;200 uuuuuuuuuuuuuuuuuu&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;filename x dummy;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data want (drop=line);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;length newvar $200.;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;SPAN style="color: #222222; font-size: 15px; text-align: -webkit-auto; background-color: rgba(255, 255, 255, 0.917969);"&gt;do until (last.id&lt;/SPAN&gt;&lt;SPAN style="color: #222222; font-size: 15px; text-align: -webkit-auto; background-color: rgba(255, 255, 255, 0.917969);"&gt;);&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; set have;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; by id;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; file x;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; put line +(-1) @;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;end;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;newvar = _file_;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;put;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; text-align: -webkit-auto; font-size: 15px; background-color: rgba(255, 255, 255, 0.917969); font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 May 2012 05:52:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111565#M23111</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-05-12T05:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Combining the same variable on different records into a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111566#M23112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or just use the CATS() function instead of playing tricks with output file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; length newvar $200;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do until (last.id);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newvar=cats(newvar,line);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; drop line;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Frequently I will also add this line before the LENGTH statement to force the new variable be after the original variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;if 0 then set have;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 May 2012 13:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111566#M23112</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-05-12T13:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Combining the same variable on different records into a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111567#M23113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... sure, CATS works (and in this case, better) ... not sure if _file_ is a trick or just showing another way to concatenate values&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 May 2012 15:36:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111567#M23113</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-05-12T15:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Combining the same variable on different records into a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111568#M23114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the wonderul solution ppl!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I went with Linlin's suggestion&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had one additional question. In the above problem how can we have newline to be dynamic?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As in if we do not know the maximum number of rows that can have the same id. Does SAS support dynamic variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have scenarios where newline can be 100, 350 or 500 and could be even more.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 10:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111568#M23114</guid>
      <dc:creator>kdm</dc:creator>
      <dc:date>2012-05-14T10:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Combining the same variable on different records into a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111569#M23115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... use Linlin's data and Tom's data step, insert PROC SQL in between to find the maximum length of the combined data across the IDs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data have;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;input id line $50.;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;cards;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;100 abcdefghijkollldsdksjd&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;100 djsjdklsjdksdlsldklskdsld&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;100 djskdjsldjlsdjlsdjlsdljskdjskdjskdioeioeoeoe&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;100 jksldksldklsldklsdksldksldklskdls&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;100 djsldksldksldklsdkdadskldkasldklsdksdklskdsk&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;200 djksldklskdlskdls&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;200 uuuuuuuuuuuuuuuuuu&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;proc sql noprint;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;select max(lng) into :maxlng separated by ' ' from (select sum(length(line)) as lng from have group by id) ;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data want ;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; length newvar $&amp;amp;maxlng;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; do until (last.id);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by id;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newvar=cats(newvar,line);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; drop line;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: arial, helvetica, sans-serif;"&gt;ps the "separated by" removes any blanks from around the value of the&amp;nbsp; macro variable ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;A href="http://www.sascommunity.org/wiki/Tips:Strip_Blanks_from_PROC_SQL-Created_Macro_Variable_Values" title="http://www.sascommunity.org/wiki/Tips:Strip_Blanks_from_PROC_SQL-Created_Macro_Variable_Values"&gt;http://www.sascommunity.org/wiki/Tips:Strip_Blanks_from_PROC_SQL-Created_Macro_Variable_Values&lt;/A&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 15:59:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-the-same-variable-on-different-records-into-a-single/m-p/111569#M23115</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-05-14T15:59:54Z</dc:date>
    </item>
  </channel>
</rss>

