<?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 Collapse Transactional Data by Customer and Preserve Order of Transaction Type in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Collapse-Transactional-Data-by-Customer-and-Preserve-Order-of/m-p/452025#M283863</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given data of the following format, how could one collapse the transactional records to a single row (customer) and preserve the order of the transaction type?&amp;nbsp; I.e. the result using the code below should be a single row for customer A with transaction history of 'offline-online-offline':&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
   input cust $ type $;
   datalines;
A offline
A offline
A offline
A offline
A offline
A online
A online
A online
A online
A online
A online
A offline
A offline
A offline
A offline
A offline
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Assume the data is already sorted by customer and in ascending order by a timestamp variable not shown here.&amp;nbsp; Customers could have a single interaction type or up to 9 different types, with the average number of customer interactions is approx. 50 per customer.&amp;nbsp; Any assistance is much appreciated.&amp;nbsp; Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 06 Apr 2018 18:06:40 GMT</pubDate>
    <dc:creator>P5C768</dc:creator>
    <dc:date>2018-04-06T18:06:40Z</dc:date>
    <item>
      <title>Collapse Transactional Data by Customer and Preserve Order of Transaction Type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collapse-Transactional-Data-by-Customer-and-Preserve-Order-of/m-p/452025#M283863</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given data of the following format, how could one collapse the transactional records to a single row (customer) and preserve the order of the transaction type?&amp;nbsp; I.e. the result using the code below should be a single row for customer A with transaction history of 'offline-online-offline':&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
   input cust $ type $;
   datalines;
A offline
A offline
A offline
A offline
A offline
A online
A online
A online
A online
A online
A online
A offline
A offline
A offline
A offline
A offline
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Assume the data is already sorted by customer and in ascending order by a timestamp variable not shown here.&amp;nbsp; Customers could have a single interaction type or up to 9 different types, with the average number of customer interactions is approx. 50 per customer.&amp;nbsp; Any assistance is much appreciated.&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Apr 2018 18:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collapse-Transactional-Data-by-Customer-and-Preserve-Order-of/m-p/452025#M283863</guid>
      <dc:creator>P5C768</dc:creator>
      <dc:date>2018-04-06T18:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Collapse Transactional Data by Customer and Preserve Order of Transaction Type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collapse-Transactional-Data-by-Customer-and-Preserve-Order-of/m-p/452049#M283864</link>
      <description>&lt;P&gt;I think this may get you started:&lt;/P&gt;
&lt;PRE&gt;Data want;
   set sample;
   length longtext $500; /*this number has to be long enough to hold thelongest expected string*/
   retain longtext;
   by cust notsorted type;
   if first.cust then call missing(longtext);
   if first.type then longtext=catx('-',longtext,type);
   if last.cust;
run;&lt;/PRE&gt;
&lt;P&gt;Any not named variables would have the values from the last record for the cust value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Apr 2018 18:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collapse-Transactional-Data-by-Customer-and-Preserve-Order-of/m-p/452049#M283864</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-06T18:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Collapse Transactional Data by Customer and Preserve Order of Transaction Type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Collapse-Transactional-Data-by-Customer-and-Preserve-Order-of/m-p/454481#M283865</link>
      <description>&lt;P&gt;Another great solution from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;!&amp;nbsp; Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 15:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Collapse-Transactional-Data-by-Customer-and-Preserve-Order-of/m-p/454481#M283865</guid>
      <dc:creator>P5C768</dc:creator>
      <dc:date>2018-04-16T15:37:14Z</dc:date>
    </item>
  </channel>
</rss>

