<?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: Create 3 separate dates from one date variable using a condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-3-separate-dates-from-one-date-variable-using-a-condition/m-p/816694#M322384</link>
    <description>It's an error</description>
    <pubDate>Mon, 06 Jun 2022 18:15:24 GMT</pubDate>
    <dc:creator>nab102</dc:creator>
    <dc:date>2022-06-06T18:15:24Z</dc:date>
    <item>
      <title>Create 3 separate dates from one date variable using a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-3-separate-dates-from-one-date-variable-using-a-condition/m-p/816651#M322360</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;This is the dataset I have . I have one date of which a book was purchased. Each customer has a unique Id (shown as customer_id below) . So for each customer have a purchase date. I want to separate the purchase date into three separate group.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.PNG" style="width: 358px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72008i0211DB269F0AE0C1/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.PNG" alt="1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I want. For each customer Id, the first date is the same as the purchase_date, so everyone has a purchase date. And their subsequent dates after the purchase is recording in second date and third if they have any. So for example custome_id T002 made purchases twice, one on 09/05/2019 which will be the first date and the second purchase was on 05/07/2021 that's the second date . Since this particular customer doesn't make a third purchase, third_date is recorded as NA.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.PNG" style="width: 358px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72009iC2BB5F2DE4DF080D/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.PNG" alt="2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 14:50:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-3-separate-dates-from-one-date-variable-using-a-condition/m-p/816651#M322360</guid>
      <dc:creator>nab102</dc:creator>
      <dc:date>2022-06-06T14:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create 3 separate dates from one date variable using a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-3-separate-dates-from-one-date-variable-using-a-condition/m-p/816654#M322362</link>
      <description>&lt;P&gt;How is it that customer T007 has no 2nd date but does have a 3rd date? That seems illogical.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 15:25:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-3-separate-dates-from-one-date-variable-using-a-condition/m-p/816654#M322362</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-06T15:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create 3 separate dates from one date variable using a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-3-separate-dates-from-one-date-variable-using-a-condition/m-p/816681#M322375</link>
      <description>&lt;P&gt;1. Sort the data by Customer ID and Purchase Date&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by Customer_ID purchase_date;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2. Add a number to indicate the purchase order&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data purchaseOrder;
set have;
by Customer_ID purchase_date;
if first.customer_id then order=1;
else order+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;3. Transpose it to a wide format&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=purchaseOrder out=purchaseWide prefix=Purchase;
by CustomerID;
id order;
var purchase_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your columns will be called Purchase1, Purchase2, Purchase3 instead of first_date, second_date, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/235792"&gt;@nab102&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;This is the dataset I have . I have one date of which a book was purchased. Each customer has a unique Id (shown as customer_id below) . So for each customer have a purchase date. I want to separate the purchase date into three separate group.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.PNG" style="width: 358px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72008i0211DB269F0AE0C1/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.PNG" alt="1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I want. For each customer Id, the first date is the same as the purchase_date, so everyone has a purchase date. And their subsequent dates after the purchase is recording in second date and third if they have any. So for example custome_id T002 made purchases twice, one on 09/05/2019 which will be the first date and the second purchase was on 05/07/2021 that's the second date . Since this particular customer doesn't make a third purchase, third_date is recorded as NA.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.PNG" style="width: 358px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72009iC2BB5F2DE4DF080D/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.PNG" alt="2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 17:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-3-separate-dates-from-one-date-variable-using-a-condition/m-p/816681#M322375</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-06T17:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create 3 separate dates from one date variable using a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-3-separate-dates-from-one-date-variable-using-a-condition/m-p/816694#M322384</link>
      <description>It's an error</description>
      <pubDate>Mon, 06 Jun 2022 18:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-3-separate-dates-from-one-date-variable-using-a-condition/m-p/816694#M322384</guid>
      <dc:creator>nab102</dc:creator>
      <dc:date>2022-06-06T18:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create 3 separate dates from one date variable using a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-3-separate-dates-from-one-date-variable-using-a-condition/m-p/816697#M322387</link>
      <description>&lt;P&gt;You really don't need to add the ORDER variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC TRANSPOSE will&amp;nbsp; number the variables sequentially automatically.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=purchaseWide prefix=Purchase;
  by CustomerID;
  var purchase_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Jun 2022 18:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-3-separate-dates-from-one-date-variable-using-a-condition/m-p/816697#M322387</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-06T18:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create 3 separate dates from one date variable using a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-3-separate-dates-from-one-date-variable-using-a-condition/m-p/816724#M322401</link>
      <description>Realizing this doesn't match your output. You have your lines repeated, I only have the final line so this may not be what you need.</description>
      <pubDate>Mon, 06 Jun 2022 19:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-3-separate-dates-from-one-date-variable-using-a-condition/m-p/816724#M322401</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-06T19:17:49Z</dc:date>
    </item>
  </channel>
</rss>

