<?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: Datepart Problem in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69343#M6920</link>
    <description>The problem is I need to add Ten years to the dates for Datepart.  &lt;BR /&gt;
&lt;BR /&gt;
So would I need to do something like this:&lt;BR /&gt;
&lt;BR /&gt;
DATEPART(BASEL_BL_L.ACTIVE_TO_DTTM /1000) + MDY(1,1,1970)&lt;BR /&gt;
&lt;BR /&gt;
Thanks from the new guy,&lt;BR /&gt;
&lt;BR /&gt;
Ryan</description>
    <pubDate>Wed, 14 Jan 2009 20:35:44 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-01-14T20:35:44Z</dc:date>
    <item>
      <title>Datepart Problem</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69341#M6918</link>
      <description>I am trying to convert a number to a date in EG and it is not working, Could you help me out:&lt;BR /&gt;
&lt;BR /&gt;
I know that the number that is stored in the SAS field is in milliseconds.&lt;BR /&gt;
&lt;BR /&gt;
Example of what is in the field: &lt;BR /&gt;
253402146000000 want it converted to 12/30/9999 &lt;BR /&gt;
1228712400000 want it converted to 12/8/2008&lt;BR /&gt;
&lt;BR /&gt;
Here is an example of what I am getting:&lt;BR /&gt;
253402146000000 What I am geting 12/31/9989 &lt;BR /&gt;
1228712400000 What I am geting 12/8/1998&lt;BR /&gt;
&lt;BR /&gt;
When I use DATEPART(BASEL_BL_L.ACTIVE_TO_DTTM /1000) in a calculated field the date is off by 10 years.  I beleive that is happening because DATEPART uses 1/1/1960 to figure out the date, but this field uses 1/1/1970.&lt;BR /&gt;
&lt;BR /&gt;
How do I go about doing this?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
&lt;BR /&gt;
Ryan&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-------------Edit--------------------&lt;BR /&gt;
&lt;BR /&gt;
Also here is the code that is running....  Very simple:&lt;BR /&gt;
&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
 CREATE TABLE SASUSER.DATASET_FOR_VENDOR_REF AS SELECT BASEL_BL_L.SOURCE_SYSTEM_CD FORMAT=$3.,&lt;BR /&gt;
	 BASEL_BL_L.BASEL_BL_ID FORMAT=$32.,&lt;BR /&gt;
	 BASEL_BL_L.BASEL_BL_RK FORMAT=20.,&lt;BR /&gt;
	 BASEL_BL_L.ACTIVE_TO_DTTM FORMAT=20.,&lt;BR /&gt;
	 (DATEPART(BASEL_BL_L.ACTIVE_TO_DTTM /1000)&lt;BR /&gt;
) FORMAT=MMDDYYS10.0 AS VendorActiveToDate &lt;BR /&gt;
 FROM SASOPRSK.BASEL_BL_L AS BASEL_BL_L&lt;BR /&gt;
 WHERE BASEL_BL_L.SOURCE_SYSTEM_CD = "SMS";&lt;BR /&gt;
QUIT;

Message was edited by: rtreptow</description>
      <pubDate>Wed, 14 Jan 2009 19:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69341#M6918</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-14T19:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Datepart Problem</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69342#M6919</link>
      <description>Subtract 10 years with the following constant generated using the SAS MDY function, which creates a SAS-internal number representing 10 years, given that 1/1/1960 is a value of 0:&lt;BR /&gt;
&lt;BR /&gt;
MDY(1,1,1970)&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 14 Jan 2009 19:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69342#M6919</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-01-14T19:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: Datepart Problem</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69343#M6920</link>
      <description>The problem is I need to add Ten years to the dates for Datepart.  &lt;BR /&gt;
&lt;BR /&gt;
So would I need to do something like this:&lt;BR /&gt;
&lt;BR /&gt;
DATEPART(BASEL_BL_L.ACTIVE_TO_DTTM /1000) + MDY(1,1,1970)&lt;BR /&gt;
&lt;BR /&gt;
Thanks from the new guy,&lt;BR /&gt;
&lt;BR /&gt;
Ryan</description>
      <pubDate>Wed, 14 Jan 2009 20:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69343#M6920</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-14T20:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Datepart Problem</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69344#M6921</link>
      <description>just tried (the following is a snip from a sas log):[pre]5    * 253402146000000 want it converted to 12/30/9999 ;&lt;BR /&gt;
6    %let num =&lt;BR /&gt;
7      253402146000000&lt;BR /&gt;
8    ;&lt;BR /&gt;
9    %put %sysevalf( "30dec9989"d +0 );&lt;BR /&gt;
2932894&lt;BR /&gt;
10   %put %sysfunc( putn( &amp;amp;num/3600/24/1000, date9.));&lt;BR /&gt;
31DEC9989[/pre]&lt;BR /&gt;
So, only need to add 10 years. However, since that is not a multiple of 4, leap year days make the "10-year" adjustment subject to some more rules, &lt;BR /&gt;
   that I don't see!&lt;BR /&gt;
&lt;BR /&gt;
If I am to add 10 years (in milliseconds), how many leap days are appropriate? &lt;BR /&gt;
&lt;BR /&gt;
PeterC

forgot: also need to deduct a day (at least that is a constant number of millisecs)!&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: Peter_c</description>
      <pubDate>Thu, 15 Jan 2009 08:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69344#M6921</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-15T08:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Datepart Problem</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69345#M6922</link>
      <description>I did get it to work, here is what I did.&lt;BR /&gt;
&lt;BR /&gt;
MDY(Month(CALCULATED Datepart),Day(CALCULATED Datepart),Year(CALCULATED Datepart)+10 )&lt;BR /&gt;
&lt;BR /&gt;
Thanks sbb for helping me figure this out.&lt;BR /&gt;
&lt;BR /&gt;
The calculated field for Datepart was:&lt;BR /&gt;
DATEPART(BASEL_BL_L.ACTIVE_TO_DTTM/1000 )&lt;BR /&gt;
&lt;BR /&gt;
So here is the whole code I did:&lt;BR /&gt;
&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
 CREATE TABLE SASUSER.DATASET_FOR_VENDOR_REF AS SELECT BASEL_BL_L.SOURCE_SYSTEM_CD FORMAT=$3.,&lt;BR /&gt;
	 BASEL_BL_L.BASEL_BL_ID FORMAT=$32.,&lt;BR /&gt;
	 BASEL_BL_L.BASEL_BL_RK FORMAT=20.,&lt;BR /&gt;
	 BASEL_BL_L.ACTIVE_TO_DTTM FORMAT=20.,&lt;BR /&gt;
	 (DATEPART(BASEL_BL_L.ACTIVE_TO_DTTM/1000 )) FORMAT=MMDDYY10.0 AS Datepart,&lt;BR /&gt;
	 (MDY(Month(CALCULATED Datepart),&lt;BR /&gt;
	Day(CALCULATED Datepart),&lt;BR /&gt;
	Year(CALCULATED Datepart)+10 )&lt;BR /&gt;
) FORMAT=MMDDYY10.0 AS VendorActiveToDate2 &lt;BR /&gt;
 FROM SASOPRSK.BASEL_BL_L AS BASEL_BL_L&lt;BR /&gt;
 WHERE BASEL_BL_L.SOURCE_SYSTEM_CD = "SMS";&lt;BR /&gt;
QUIT;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks everyone..&lt;BR /&gt;
&lt;BR /&gt;
Ryan</description>
      <pubDate>Thu, 15 Jan 2009 17:03:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69345#M6922</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-15T17:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Datepart Problem</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69346#M6923</link>
      <description>if a DATEPART was 29-Feb of some leap year, what should the 10 year adjustment be ?&lt;BR /&gt;
 &lt;BR /&gt;
just curious</description>
      <pubDate>Fri, 16 Jan 2009 08:53:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69346#M6923</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-16T08:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: Datepart Problem</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69347#M6924</link>
      <description>The SAS MDY function will handle leap-year appropriately.  Stick with using SAS functions and you will happily get the correct answers when using date and datetime logic processing.  Other functions such as INTNX, INTCK, also play well with leap-year conditions.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 16 Jan 2009 12:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69347#M6924</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-01-16T12:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Datepart Problem</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69348#M6925</link>
      <description>dup

dup&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: Peter_c</description>
      <pubDate>Fri, 16 Jan 2009 12:50:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69348#M6925</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-16T12:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: Datepart Problem</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69349#M6926</link>
      <description>Scott&lt;BR /&gt;
&lt;BR /&gt;
does the MDY() function handle changing the day when adding or subtracting 10 from the year value for a 29-Feb date?&lt;BR /&gt;
This SASlog snip shows a simple demo of the problem is see with the MDY() approach[pre]203  %put %sysfunc( mdy( 2,29,2008), date9 );&lt;BR /&gt;
29FEB2008&lt;BR /&gt;
204  %put %sysfunc( mdy( 2,29,2018), date9 );&lt;BR /&gt;
WARNING: An argument to the function MDY referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.&lt;BR /&gt;
NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set to a missing value.&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Adapting the number of milliseconds works, until adding 10 years, an interval which can have 2 or 3 leap days. Some help comes from the SAMEDAY parameter of the INTNX() function for interval handling. &lt;BR /&gt;
However, I assume/hope the system, from which these milisecond timestamps  come, will have defined the way it handles leap days.&lt;BR /&gt;
&lt;BR /&gt;
or do I just mis-understand ~ should we just add the (constant) number of days or milliseconds between base-dates for SAS (1Jan1960) and the other system (1Jan1970)?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
PeterC

doh'&lt;BR /&gt;
so that was what you were suggesting with mdy(1,1,1970) !&lt;BR /&gt;
ahhhh&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: Peter_c</description>
      <pubDate>Fri, 16 Jan 2009 12:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69349#M6926</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-16T12:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Datepart Problem</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69350#M6927</link>
      <description>SAS is expecting you to assign a numeric variable with either seconds (DATETIME) or days (DATE type), and a value of zero represents 1/1/1960.  And there are minimum and maximum value range for SAS handling of date/datetime values, to consider.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
SAS Language Concepts - discussion on Dates, Times and Intervals (Chapter 8):&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/onlinedoc/91pdf/sasdoc_913/base_lrconcept_9196.pdf" target="_blank"&gt;http://support.sas.com/documentation/onlinedoc/91pdf/sasdoc_913/base_lrconcept_9196.pdf&lt;/A&gt;</description>
      <pubDate>Fri, 16 Jan 2009 18:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Datepart-Problem/m-p/69350#M6927</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-01-16T18:53:49Z</dc:date>
    </item>
  </channel>
</rss>

