<?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: combine variables with same id in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combine-variables-with-same-id/m-p/231442#M16815</link>
    <description>&lt;P&gt;Are you looking for the calculation 45-74 or a character value "45-74"? Is Number currenlty numeric or character?&lt;/P&gt;
&lt;P&gt;What if there are 3 or more records with the same value of Id?&lt;/P&gt;</description>
    <pubDate>Fri, 23 Oct 2015 19:31:50 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2015-10-23T19:31:50Z</dc:date>
    <item>
      <title>combine variables with same id</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combine-variables-with-same-id/m-p/231428#M16814</link>
      <description>&lt;P&gt;I have a table as below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id &amp;nbsp; &amp;nbsp; &amp;nbsp;number &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 45&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 74&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 33&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i need is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id &amp;nbsp; &amp;nbsp; number&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;45-74&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;33-12-15&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2015 19:33:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/combine-variables-with-same-id/m-p/231428#M16814</guid>
      <dc:creator>user24</dc:creator>
      <dc:date>2015-10-23T19:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: combine variables with same id</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combine-variables-with-same-id/m-p/231442#M16815</link>
      <description>&lt;P&gt;Are you looking for the calculation 45-74 or a character value "45-74"? Is Number currenlty numeric or character?&lt;/P&gt;
&lt;P&gt;What if there are 3 or more records with the same value of Id?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2015 19:31:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/combine-variables-with-same-id/m-p/231442#M16815</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-10-23T19:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: combine variables with same id</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combine-variables-with-same-id/m-p/231444#M16816</link>
      <description>&lt;P&gt;Sorry it wasnot clear. I updated tables. It is character values not calculation. And&amp;nbsp;yes if i have more than 2 it will be same like 12-15-17-13. Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2015 19:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/combine-variables-with-same-id/m-p/231444#M16816</guid>
      <dc:creator>user24</dc:creator>
      <dc:date>2015-10-23T19:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: combine variables with same id</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combine-variables-with-same-id/m-p/231452#M16817</link>
      <description>&lt;P&gt;Here you go..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;data in;infile datalines dlm='09'x;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;input id:$2. num: $2.;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;datalines;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;2 12&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;3 45&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;3 74&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;5 33&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;5 12&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;5 15&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;;RUN;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;proc sort;by id;run;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;data in(keep=id new_id rename=(new_id=num));&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; set in;by id;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; length new_id $3000.;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; length final_id $3000.;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; retain new_id;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; if first.id then new_id = num; else new_id=left(trim(new_id))|| '-' || num;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; if last.id then do;final_id=left(trim(new_id));output;end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Hope this helps...!!!&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2015 20:50:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/combine-variables-with-same-id/m-p/231452#M16817</guid>
      <dc:creator>kannand</dc:creator>
      <dc:date>2015-10-23T20:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: combine variables with same id</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/combine-variables-with-same-id/m-p/231454#M16818</link>
      <description>&lt;P&gt;Something like this maybe what you are looking for. You imply that the data is in order so I will assume it is sorted by the ID.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   by id;
   length numcombined $ 50 ; /* this needs to be long enough to hold the longest combination plus the -*/
   if first.id then numcombined=number;
   else numcombined = catx('-',numcombined,number);
   if last.id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Oct 2015 20:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/combine-variables-with-same-id/m-p/231454#M16818</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-10-23T20:54:27Z</dc:date>
    </item>
  </channel>
</rss>

