<?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: Calculate the Days Between Two Transactions for 4 Cohorts in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Days-Between-Two-Transactions-for-4-Cohorts/m-p/198534#M37178</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Much the same really, just one datastep rather than 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=testdata;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by var1 date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want (drop=lstdate);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set testdata;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain lstdate;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by var1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.var1 then lstdate=date;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if date in ('28sep2014'd,'28dec2014'd,'29mar2015'd,'28jun2015'd) and lag(var1)=var1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; days_between=date - lstdate;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; lstdate=date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Aug 2015 12:26:52 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-08-14T12:26:52Z</dc:date>
    <item>
      <title>Calculate the Days Between Two Transactions for 4 Cohorts</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Days-Between-Two-Transactions-for-4-Cohorts/m-p/198532#M37176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;I’m trying to calculate the days between two transactions for 4 cohorts. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;The cohorts defined by all those which purchased on on these dates: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt;"&gt;'28SEP2014'd&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt;"&gt;'28DEC2014'd&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt;"&gt;'29MAR2015'd&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt;"&gt;'28JUN2015'd&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;And it’s the difference between the last &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;transaction before&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt; the transaction date which define the cohorts. Here is an example:&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;I start with this. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="1" cellpadding="0" cellspacing="0" jive-data-cell="{&amp;quot;color&amp;quot;:&amp;quot;#575757&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;-webkit-right&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;NaN&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;transparent&amp;quot;,&amp;quot;fontFamily&amp;quot;:&amp;quot;arial,helvetica,sans-serif&amp;quot;}" jive-data-header="{&amp;quot;color&amp;quot;:&amp;quot;#FFFFFF&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#6690BC&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;center&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;}" style="width: 174px; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="38" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;&lt;STRONG&gt;CUSTOMER_ID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl66" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;&lt;STRONG&gt;transaction_date&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;2312544&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;12-Oct-14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;2312544&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;21-Oct-14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;2312544&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;19-Nov-14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;2312544&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;11-Dec-14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl69" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;&lt;SPAN style="color: #ff0000;"&gt;2312544&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl70" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;&lt;SPAN style="color: #ff0000;"&gt;28-Dec-14&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;2312544&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;9-Jan-15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;2312544&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;10-Jan-15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;2312544&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;11-Jan-15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;2616131&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;10-Aug-08&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;2616131&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;7-Dec-08&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;2616131&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;16-Dec-12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;2616131&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;12-Apr-13&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;2616131&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;24-Jul-13&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl69" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;&lt;SPAN style="color: #ff0000;"&gt;2616131&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl70" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;&lt;SPAN style="color: #ff0000;"&gt;28-Sep-14&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;2616131&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;3-Nov-14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;2616131&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;9-Mar-15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl69" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;&lt;SPAN style="color: #ff0000;"&gt;24526667&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl70" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;&lt;SPAN style="color: #ff0000;"&gt;28-Jun-15&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl71" height="20" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;&lt;SPAN style="color: #ff0000;"&gt;84895398&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl72" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;&lt;SPAN style="color: #ff0000;"&gt;29-Mar-15&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;5555666&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;16-Dec-12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;5555666&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;12-Apr-13&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;5555666&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;30-Jul-13&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl69" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;&lt;SPAN style="color: #ff0000;"&gt;5555666&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl70" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;&lt;SPAN style="color: #ff0000;"&gt;28-Sep-14&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl69" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;5555666&lt;/TD&gt;&lt;TD class="xl70" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;30-Sep-14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl69" height="19" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="64"&gt;5555666&lt;/TD&gt;&lt;TD class="xl70" style="color: #575757; text-align: -webkit-right; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;15-Oct-14&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;Then I should get this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" cellpadding="0" cellspacing="0" jive-data-cell="{&amp;quot;color&amp;quot;:&amp;quot;#575757&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;left&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;NaN&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;transparent&amp;quot;,&amp;quot;fontFamily&amp;quot;:&amp;quot;arial,helvetica,sans-serif&amp;quot;}" jive-data-header="{&amp;quot;color&amp;quot;:&amp;quot;#FFFFFF&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#6690BC&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;center&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;}" style="width: 211px; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="26" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="101"&gt;&lt;STRONG&gt;CUSTOMER_ID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl66" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;&lt;STRONG&gt;transaction_date&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="101"&gt;2312544&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;11-Dec-14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl69" height="19" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="101"&gt;&lt;SPAN style="color: #ff0000;"&gt;2312544&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl70" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;&lt;SPAN style="color: #ff0000;"&gt;28-Dec-14&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="101"&gt;2616131&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;24-Jul-13&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl69" height="19" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="101"&gt;&lt;SPAN style="color: #ff0000;"&gt;2616131&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl70" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;&lt;SPAN style="color: #ff0000;"&gt;28-Sep-14&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="19" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="101"&gt;5555666&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;30-Jul-13&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl69" height="19" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="101"&gt;&lt;SPAN style="color: #ff0000;"&gt;5555666&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl70" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="110"&gt;&lt;SPAN style="color: #ff0000;"&gt;28-Sep-14&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;Noticed these two observations were dropped from above because these customers had no previous transactions &lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="margin-left: 4.65pt;" width="218"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border: solid black 1.0pt; background: yellow; padding: 0 5.4pt 0 5.4pt;" valign="top" width="80"&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;24526667&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: solid black 1.0pt; border-left: none; background: yellow; padding: 0 5.4pt 0 5.4pt;" valign="top" width="138"&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;28-Jun-15&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: solid black 1.0pt; border-top: none; background: yellow; padding: 0 5.4pt 0 5.4pt;" valign="top" width="80"&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;84895398&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid black 1.0pt; border-right: solid black 1.0pt; background: yellow; padding: 0 5.4pt 0 5.4pt;" valign="top" width="138"&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;SPAN style="color: black;"&gt;29-Mar-15&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then the final&amp;nbsp; output should look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" cellpadding="0" cellspacing="0" jive-data-cell="{&amp;quot;color&amp;quot;:&amp;quot;#575757&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;left&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;NaN&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;transparent&amp;quot;,&amp;quot;fontFamily&amp;quot;:&amp;quot;arial,helvetica,sans-serif&amp;quot;}" jive-data-header="{&amp;quot;color&amp;quot;:&amp;quot;#FFFFFF&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#6690BC&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;center&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;}" style="width: 275px; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="26" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="98"&gt;&lt;STRONG&gt;CUSTOMER_ID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl65" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="101"&gt;&lt;STRONG&gt;transaction_date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl65" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="76"&gt;&lt;STRONG&gt;Days Between &lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="98"&gt;2312544&lt;/TD&gt;&lt;TD class="xl67" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="101"&gt;28-Dec-14&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;"&gt;17&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="98"&gt;2616131&lt;/TD&gt;&lt;TD class="xl67" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="101"&gt;28-Sep-14&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;"&gt;431&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="19" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="98"&gt;5555666&lt;/TD&gt;&lt;TD class="xl67" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;" width="101"&gt;28-Sep-14&lt;/TD&gt;&lt;TD class="xl68" style="color: #575757; text-align: left; padding: 0px; font-family: arial, helvetica, sans-serif; background-color: transparent;"&gt;425&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any assistance will be greatly appreciated. Thanks!!! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 18:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Days-Between-Two-Transactions-for-4-Cohorts/m-p/198532#M37176</guid>
      <dc:creator>JFM</dc:creator>
      <dc:date>2015-08-13T18:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Days Between Two Transactions for 4 Cohorts</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Days-Between-Two-Transactions-for-4-Cohorts/m-p/198533#M37177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. You can try this solution. Maybe not the most sophisticated but it should work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data TestData;&lt;/P&gt;&lt;P&gt;infile datalines dlm=' ';&lt;/P&gt;&lt;P&gt;input Var1&amp;nbsp; date date9. ;&lt;/P&gt;&lt;P&gt;format date date9.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;2312544 12-Oct-14&lt;/P&gt;&lt;P&gt;2312544 21-Oct-14&lt;/P&gt;&lt;P&gt;2312544 19-Nov-14&lt;/P&gt;&lt;P&gt;2312544 11-Dec-14&lt;/P&gt;&lt;P&gt;2312544 28-Dec-14&lt;/P&gt;&lt;P&gt;2312544 9-Jan-15&lt;/P&gt;&lt;P&gt;2312544 10-Jan-15&lt;/P&gt;&lt;P&gt;2312544 11-Jan-15&lt;/P&gt;&lt;P&gt;2616131 10-Aug-08&lt;/P&gt;&lt;P&gt;2616131 7-Dec-08&lt;/P&gt;&lt;P&gt;2616131 16-Dec-12&lt;/P&gt;&lt;P&gt;2616131 12-Apr-13&lt;/P&gt;&lt;P&gt;2616131 24-Jul-13&lt;/P&gt;&lt;P&gt;2616131 28-Sep-14&lt;/P&gt;&lt;P&gt;2616131 3-Nov-14&lt;/P&gt;&lt;P&gt;2616131 9-Mar-15&lt;/P&gt;&lt;P&gt;24526667 28-Jun-15&lt;/P&gt;&lt;P&gt;84895398 29-Mar-15&lt;/P&gt;&lt;P&gt;5555666 16-Dec-12&lt;/P&gt;&lt;P&gt;5555666 12-Apr-13&lt;/P&gt;&lt;P&gt;5555666 30-Jul-13&lt;/P&gt;&lt;P&gt;5555666 28-Sep-14&lt;/P&gt;&lt;P&gt;5555666 30-Sep-14&lt;/P&gt;&lt;P&gt;5555666 15-Oct-14&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data testdata;&lt;/P&gt;&lt;P&gt;set testdata;&lt;/P&gt;&lt;P&gt;if date in('28SEP2014'd, '28DEC2014'd, '29MAR2015'd, '28JUN2015'd)&lt;/P&gt;&lt;P&gt;&amp;nbsp; then flag=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc Sort Data=testdata Out= test_sorted;&lt;/P&gt;&lt;P&gt;By var1 date ;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Want;&lt;/P&gt;&lt;P&gt;set test_sorted;&lt;/P&gt;&lt;P&gt;by var1;&lt;/P&gt;&lt;P&gt;if first.var1 and last.var1 then delete; * singel observations;&lt;/P&gt;&lt;P&gt;lag_date=lag(date);&lt;/P&gt;&lt;P&gt;if flag then days=date-lag_date;&lt;/P&gt;&lt;P&gt;if flag;&lt;/P&gt;&lt;P&gt;drop flag;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Aug 2015 12:03:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Days-Between-Two-Transactions-for-4-Cohorts/m-p/198533#M37177</guid>
      <dc:creator>JonasE</dc:creator>
      <dc:date>2015-08-14T12:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Days Between Two Transactions for 4 Cohorts</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Days-Between-Two-Transactions-for-4-Cohorts/m-p/198534#M37178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Much the same really, just one datastep rather than 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=testdata;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by var1 date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want (drop=lstdate);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set testdata;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain lstdate;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by var1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.var1 then lstdate=date;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if date in ('28sep2014'd,'28dec2014'd,'29mar2015'd,'28jun2015'd) and lag(var1)=var1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; days_between=date - lstdate;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; lstdate=date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Aug 2015 12:26:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Days-Between-Two-Transactions-for-4-Cohorts/m-p/198534#M37178</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-08-14T12:26:52Z</dc:date>
    </item>
  </channel>
</rss>

