<?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: formatting date variable returns JAN1960 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/formatting-date-variable-returns-JAN1960/m-p/682804#M206721</link>
    <description>1. I'm creating a new variable called Report_Month based off the Date variable&lt;BR /&gt;2. I think I know where I was going wrong. I was using datepart&lt;BR /&gt;The below worked. Thanks for your input, it steered me in the right direction. I was over complicating it.&lt;BR /&gt;Report_Month=Date;&lt;BR /&gt;format Report_Month monyy7.;&lt;BR /&gt;</description>
    <pubDate>Wed, 09 Sep 2020 23:40:53 GMT</pubDate>
    <dc:creator>Haydn</dc:creator>
    <dc:date>2020-09-09T23:40:53Z</dc:date>
    <item>
      <title>formatting date variable returns JAN1960</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-date-variable-returns-JAN1960/m-p/682797#M206716</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a variable called &lt;STRONG&gt;"Date"&lt;/STRONG&gt;. The dataset is imported from a SharePoint list and is imported as &lt;STRONG&gt;DATE9.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have coded&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Report_Month=datepart(Date);
format Report_Month monyy7.;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;An example of the "Date" variable is 08SEP2020. When looking at the properties of this variable it's Type(Numeric),Group (Date) Format(DATE9.) and Informat (DATE9.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This returns JAN1960 for every row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please assist?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 23:13:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-date-variable-returns-JAN1960/m-p/682797#M206716</guid>
      <dc:creator>Haydn</dc:creator>
      <dc:date>2020-09-09T23:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: formatting date variable returns JAN1960</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-date-variable-returns-JAN1960/m-p/682799#M206717</link>
      <description>&lt;P&gt;Your DATE variable is a datetime, not a date.&lt;/P&gt;
&lt;P&gt;Format it with format DATETIME20.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 23:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-date-variable-returns-JAN1960/m-p/682799#M206717</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-09T23:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: formatting date variable returns JAN1960</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-date-variable-returns-JAN1960/m-p/682801#M206718</link>
      <description>Thank you for your quick response.&lt;BR /&gt;I coded&lt;BR /&gt;Report_Month=datepart(Date);&lt;BR /&gt;format Report_Month DATETIME20.;&lt;BR /&gt;&lt;BR /&gt;and it returns 01JAN1960:00:00:00</description>
      <pubDate>Wed, 09 Sep 2020 23:28:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-date-variable-returns-JAN1960/m-p/682801#M206718</guid>
      <dc:creator>Haydn</dc:creator>
      <dc:date>2020-09-09T23:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: formatting date variable returns JAN1960</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-date-variable-returns-JAN1960/m-p/682803#M206720</link>
      <description>&lt;P&gt;1. Why do you format variable REPORT_MONTH when we are discussing variable DATE?&lt;/P&gt;
&lt;P&gt;2. What' s the values when formatted with format comma32.16 ?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 23:34:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-date-variable-returns-JAN1960/m-p/682803#M206720</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-09T23:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: formatting date variable returns JAN1960</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-date-variable-returns-JAN1960/m-p/682804#M206721</link>
      <description>1. I'm creating a new variable called Report_Month based off the Date variable&lt;BR /&gt;2. I think I know where I was going wrong. I was using datepart&lt;BR /&gt;The below worked. Thanks for your input, it steered me in the right direction. I was over complicating it.&lt;BR /&gt;Report_Month=Date;&lt;BR /&gt;format Report_Month monyy7.;&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Sep 2020 23:40:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-date-variable-returns-JAN1960/m-p/682804#M206721</guid>
      <dc:creator>Haydn</dc:creator>
      <dc:date>2020-09-09T23:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: formatting date variable returns JAN1960</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formatting-date-variable-returns-JAN1960/m-p/682807#M206723</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/41546"&gt;@Haydn&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you tell me the exact data you are exporting from SharePoint?&amp;nbsp; &amp;nbsp;Is it text that represents a date or is it an actual DateTime field?&amp;nbsp; If you are exporting a DateTime field, if I recall correctly, you have to compensate for the difference between the way .Net represents a DateTime and SAS.&amp;nbsp; SAS DateTime values are a count of seconds starting on 01 Jan 1960.&amp;nbsp; By contrast, .Net represents a DateTime value as the number of seconds 01 Jan 0001.&amp;nbsp; There are&amp;nbsp;715,509 days between 01 Jan 0001 and 01 Jan 1960 (I looked it up), and there are 84,600 seconds per day.&amp;nbsp; You would need to adjust a SharePoint DateTime value by subrtracting (715,509 * 84600) from it if I'm remembering my math correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're reading character representations of a date, for example 09/09/2020, then you need to make sure you're using a Date format if it's a date (example 09/09/2020) or a DateTime format if the value is represents a DateTime value (example 2020/09/09:16:57:00).&amp;nbsp; Be sure to used Date formats for dates and DateTime formats for DateTimes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition, SAS doesn't consider 4000 or 8000 to be leap years.&amp;nbsp; If you're dealing with long term dates, you might have to compensate for that difference in what is considered a leap year.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 23:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formatting-date-variable-returns-JAN1960/m-p/682807#M206723</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-09-09T23:58:00Z</dc:date>
    </item>
  </channel>
</rss>

