<?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 do I convert SAS Dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250700#M47295</link>
    <description>&lt;P&gt;Then convert your datetimes to dates using DATEPART()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Feb 2016 20:35:31 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-02-17T20:35:31Z</dc:date>
    <item>
      <title>How do I convert SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250676#M47286</link>
      <description>&lt;P&gt;Im New to SAS Base and have been given a project and this is the question&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On average how many days does it take ADW to deliver products between the order date and shipment date? Show results on a monthly basis, this will help the business understand its low performing delivery months and identify the drivers.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The business would also like to know the order to shipment performance by regions, state and country.&lt;/LI&gt;&lt;LI&gt;Which product category and sub product categories is late shipment predominant to?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Please note: SLA for shipments is next day between the order date and ship date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have Identified the data that I need to use but I cant figure out the first step of calculating the days it takes to ship because the datdiff function doesnt work on the imported data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Dates Looks Like this on both order and ship dates.&lt;/P&gt;&lt;P&gt;08AUG2005:00:00:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to figure this out with just ship date and was using this code but I kept getting number insted of dates&amp;nbsp;when it converted:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Date (Keep = EmployeeKey SalesTerritoryKey ShipDate DATEPART_SHIPDATE PUT_SHIPDATE INPUT_SHIPDATE );&lt;BR /&gt;Set project.dbo_factresellersales ;&lt;BR /&gt;Informat ShipDate ANYDTDTEw.;&lt;BR /&gt;DATEPART_SHIPDATE = datepart(ShipDate);&lt;BR /&gt;PUT_SHIPDATE = PUT(DATEPART_SHIPDATE, date9.);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cant figure out how to convert the dates from datetime to date so I can use datdiff.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 19:01:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250676#M47286</guid>
      <dc:creator>U12345</dc:creator>
      <dc:date>2016-02-17T19:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250682#M47288</link>
      <description>&lt;P&gt;Without a date format applied to the date value you get an integer that is the number of days since 1 Jan 1960. To see the date apply a format such as mmddyy10. or date9. It looks like your DATEPART_SHIPDATE should be okay, just not formatted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would need two date values but I can't tell from you code if you have another or what it's name might be.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 19:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250682#M47288</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-17T19:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250690#M47290</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data import;
input
		employee : $10.
		sales_territory : $10. 
		order_date: mmddyy10. 
		ship_date: mmddyy10.;
format order_date ship_date mmddyy10.; *shows dates as dates instead of numbers;
cards;
John East 1/1/2015 1/5/2015
Bob East 1/1/2015 1/4/2015
John West 1/1/2015 1/3/2015
Bob West 1/1/2015 1/2/2015
John North 1/1/2015 1/1/2015
Bob North 1/1/2015 1/6/2015
;
run;

data have;
set import;
date_diff = intck('day',order_date,ship_date);
run;

proc means data=have;
class sales_territory;*Change to the category/categories that you're interested in; 
var date_diff;
output out=want
	n=cnt
	mean=avg;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You're on the right track with datepart()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dates are stored as numbers with&amp;nbsp;1/1/1960 =&amp;nbsp;1, 1/2/1960 = 2, &amp;amp;c. To see them as dates, you need to format them with something, like mmddyy10., or date9., &amp;amp;c.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can show differences by subtracting them, or using the intck() function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as displaying the dimensions and interactions with regard to averages, proc means will probably suit what you're doing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 19:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250690#M47290</guid>
      <dc:creator>DanZ</dc:creator>
      <dc:date>2016-02-17T19:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250697#M47293</link>
      <description>&lt;P&gt;I have changed my code to include format but in the output data for ShipDate I get are asterix where the date is meant to be. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Date (Keep = EmployeeKey SalesTerritoryKey ShipDate DATEPART_SHIPDATE PUT_SHIPDATE );&lt;BR /&gt;Set project.dbo_factresellersales ;&lt;BR /&gt;Format ShipDate mmddyy10. OrderDate mmddyy10.;&lt;BR /&gt;DATEPART_SHIPDATE = datepart(ShipDate);&lt;BR /&gt;PUT_SHIPDATE = PUT(DATEPART_SHIPDATE, date9.);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Run;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 20:25:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250697#M47293</guid>
      <dc:creator>U12345</dc:creator>
      <dc:date>2016-02-17T20:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250699#M47294</link>
      <description>&lt;P&gt;I tired that but since my dates are in a datetime format it dosent seem to caluclate using intck().&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 20:30:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250699#M47294</guid>
      <dc:creator>U12345</dc:creator>
      <dc:date>2016-02-17T20:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250700#M47295</link>
      <description>&lt;P&gt;Then convert your datetimes to dates using DATEPART()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 20:35:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250700#M47295</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-17T20:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250701#M47296</link>
      <description>&lt;P&gt;Convert to dates with the datepart() function before you&amp;nbsp;calculate&amp;nbsp;the difference between the dates.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 20:37:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250701#M47296</guid>
      <dc:creator>DanZ</dc:creator>
      <dc:date>2016-02-17T20:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250702#M47297</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Date 
(Keep = EmployeeKey SalesTerritoryKey ShipDate DATEPART_SHIPDATE PUT_SHIPDATE );

Set project.dbo_factresellersales ;

Format DATEPART_SHIPDATE DATEPART_OrderDATE  mmddyy10. shipDate OrderDate  datetime21.;

DATEPART_SHIPDATE = datepart(ShipDate);
DATEPART_OrderDATE = datepart(orderDate);
datediff=datepart_orderdate-datepart_shipdate;

Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Feb 2016 20:37:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250702#M47297</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-17T20:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250707#M47298</link>
      <description>&lt;P&gt;Thanks alot, I just realised what i was doing wrong.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 20:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250707#M47298</guid>
      <dc:creator>U12345</dc:creator>
      <dc:date>2016-02-17T20:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250710#M47299</link>
      <description>&lt;P&gt;Thanks this helped alot. I understand what I was doing wrong&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 20:46:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-SAS-Dates/m-p/250710#M47299</guid>
      <dc:creator>U12345</dc:creator>
      <dc:date>2016-02-17T20:46:36Z</dc:date>
    </item>
  </channel>
</rss>

