<?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: Date conversion SPSS numeric to SAS date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-conversion-SPSS-numeric-to-SAS-date/m-p/939067#M368777</link>
    <description>&lt;P&gt;Easy to convert the value to a SAS datetime value add the result of dhms('14OCT1582'd,0,0,0)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   x=13759718400;
   offset = dhms('14OCT1582'd,0,0,0);
   SASDatetime = x+offset;
   format SASDatetime datetime20.;
   datevalue=datepart(x);
   format datevalue date9.;
run;&lt;/PRE&gt;
&lt;P&gt;If you want a DATE value then extract using the DATEPART function.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Aug 2024 14:09:29 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-08-13T14:09:29Z</dc:date>
    <item>
      <title>Date conversion SPSS numeric to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-conversion-SPSS-numeric-to-SAS-date/m-p/939060#M368775</link>
      <description>&lt;P&gt;I have imported SPSS files (.sav) into SAS Viya via proc import. But the date variables are not converted into SAS dates. After some investigation I found that the value I have got is a numeric value representing the number of seconds since October 14 year 1582.&amp;nbsp;For example the number&amp;nbsp;13759718400 represents&amp;nbsp;24-Oct-2018.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a SAS function to translate this numeric value to a SAS date variable? Or has someone here invented the code needed for this conversion?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I still have the option to save my spss file into a sas dataset and then import it.&amp;nbsp; I have checked that the date variables will be ok.&amp;nbsp; But now I'm curious to know if there is a very simple solution to my problem. Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 13:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-conversion-SPSS-numeric-to-SAS-date/m-p/939060#M368775</guid>
      <dc:creator>vanja</dc:creator>
      <dc:date>2024-08-13T13:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Date conversion SPSS numeric to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-conversion-SPSS-numeric-to-SAS-date/m-p/939062#M368776</link>
      <description>&lt;P&gt;See&amp;nbsp;&lt;A href="https://marc.info/?l=sas-l&amp;amp;m=116624449238415&amp;amp;w=2" target="_blank"&gt;https://marc.info/?l=sas-l&amp;amp;m=116624449238415&amp;amp;w=2&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 13:48:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-conversion-SPSS-numeric-to-SAS-date/m-p/939062#M368776</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-08-13T13:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Date conversion SPSS numeric to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-conversion-SPSS-numeric-to-SAS-date/m-p/939067#M368777</link>
      <description>&lt;P&gt;Easy to convert the value to a SAS datetime value add the result of dhms('14OCT1582'd,0,0,0)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   x=13759718400;
   offset = dhms('14OCT1582'd,0,0,0);
   SASDatetime = x+offset;
   format SASDatetime datetime20.;
   datevalue=datepart(x);
   format datevalue date9.;
run;&lt;/PRE&gt;
&lt;P&gt;If you want a DATE value then extract using the DATEPART function.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 14:09:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-conversion-SPSS-numeric-to-SAS-date/m-p/939067#M368777</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-13T14:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: Date conversion SPSS numeric to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-conversion-SPSS-numeric-to-SAS-date/m-p/939782#M368962</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Thank you for taking the time to solve my problem!&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2024 14:19:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-conversion-SPSS-numeric-to-SAS-date/m-p/939782#M368962</guid>
      <dc:creator>vanja</dc:creator>
      <dc:date>2024-08-18T14:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Date conversion SPSS numeric to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-conversion-SPSS-numeric-to-SAS-date/m-p/939783#M368963</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;Thank you, the solution you provided link to also worked.&lt;/P&gt;
&lt;PRE&gt;days = datespss/86400;
datesas = date() - ( date() - MDY(10,14,1582) - days );&lt;BR /&gt;format datesas date9.;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2024 14:23:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-conversion-SPSS-numeric-to-SAS-date/m-p/939783#M368963</guid>
      <dc:creator>vanja</dc:creator>
      <dc:date>2024-08-18T14:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Date conversion SPSS numeric to SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-conversion-SPSS-numeric-to-SAS-date/m-p/939787#M368965</link>
      <description>&lt;P&gt;Actually that value represents the DATETIME value&amp;nbsp;24OCT2018:00:00:00.&amp;nbsp; To convert the result to a DATE value use the DATEPART() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just add '14OCT1582:00:00'dt to it to convert it to a SAS datetime value.&lt;/P&gt;
&lt;PRE&gt;1    data test;
2      spss_dt = 13759718400;
3      sas_dt = spss_dt + '14OCT1582:00:00'dt ;
4      dt = sas_dt;
5      date = datepart(dt);
6      format spss_dt sas_dt comma15. dt datetime19. date date9.;
7      put (_all_) (=/);
8    run;


spss_dt=13,759,718,400
sas_dt=1,855,958,400
dt=24OCT2018:00:00:00
date=24OCT2018
NOTE: The data set WORK.TEST has 1 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2024 17:20:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-conversion-SPSS-numeric-to-SAS-date/m-p/939787#M368965</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-18T17:20:24Z</dc:date>
    </item>
  </channel>
</rss>

