<?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 to merge variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-variables/m-p/241763#M55731</link>
    <description>&lt;P&gt;And if you don't understand the do loop before the SET statement here's another, old fashioned method.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh﻿&lt;/a&gt;&amp;nbsp;solution is probably more efficient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by id;

length var $100.;
retain var;

if first.id then call missing(var);
var=catx('/', var, text);

if last.id then output;
run;

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 04 Jan 2016 23:10:42 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-01-04T23:10:42Z</dc:date>
    <item>
      <title>how to merge variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-variables/m-p/241758#M55729</link>
      <description>&lt;P&gt;I have data something like this -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id1&amp;nbsp;&amp;nbsp; abc&lt;/P&gt;
&lt;P&gt;id1&amp;nbsp;&amp;nbsp; def&lt;/P&gt;
&lt;P&gt;id2&amp;nbsp;&amp;nbsp; pqr&lt;/P&gt;
&lt;P&gt;id2&amp;nbsp;&amp;nbsp; rst&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;------&amp;nbsp;&amp;nbsp; etc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to have like this in output dataset -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id1&amp;nbsp; abc/def&lt;/P&gt;
&lt;P&gt;id2&amp;nbsp;&amp;nbsp; pqr/rst&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks in advance,&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 22:56:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-variables/m-p/241758#M55729</guid>
      <dc:creator>sasbasls</dc:creator>
      <dc:date>2016-01-04T22:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-variables/m-p/241761#M55730</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id $ text $;
cards;
id1   abc
id1   def
id2   pqr
id2   rst
;

data want;
length alltext $30; /* Please adapt the length 30 to your needs! */
do until(last.id);
  set have;
  by id;
  alltext=catx('/', alltext, text);
end;
drop text;
run;

proc print data=want;
var id alltext;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to have ID as the first variable in the dataset (and not only in the output), you can move the LENGTH statement after the SET statement, immediately before the assignment &lt;FONT face="courier new,courier"&gt;alltext=...&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 23:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-variables/m-p/241761#M55730</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-01-04T23:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-variables/m-p/241763#M55731</link>
      <description>&lt;P&gt;And if you don't understand the do loop before the SET statement here's another, old fashioned method.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh﻿&lt;/a&gt;&amp;nbsp;solution is probably more efficient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by id;

length var $100.;
retain var;

if first.id then call missing(var);
var=catx('/', var, text);

if last.id then output;
run;

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Jan 2016 23:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-variables/m-p/241763#M55731</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-04T23:10:42Z</dc:date>
    </item>
  </channel>
</rss>

