<?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 How to convert a numeric to date format in SAS? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-numeric-to-date-format-in-SAS/m-p/870411#M343789</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a dataset with date variables in numeric form, for example, 20984. I would like change it to YYYYMMDD10.&lt;/P&gt;&lt;P&gt;I have attempted&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data TESTDATA;&lt;/P&gt;&lt;P&gt;Set TESTDATA;&lt;/P&gt;&lt;P&gt;mortality = input (put(deathdate, 8.) YYMMDD10.);&lt;/P&gt;&lt;P&gt;format mortality YYMMDD10.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;But it failed and provides values for example 2002-07-23 which is incorrect. The data is from year 2016 and 2017.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated. Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 18 Apr 2023 17:56:48 GMT</pubDate>
    <dc:creator>WishShahid</dc:creator>
    <dc:date>2023-04-18T17:56:48Z</dc:date>
    <item>
      <title>How to convert a numeric to date format in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-numeric-to-date-format-in-SAS/m-p/870411#M343789</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a dataset with date variables in numeric form, for example, 20984. I would like change it to YYYYMMDD10.&lt;/P&gt;&lt;P&gt;I have attempted&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data TESTDATA;&lt;/P&gt;&lt;P&gt;Set TESTDATA;&lt;/P&gt;&lt;P&gt;mortality = input (put(deathdate, 8.) YYMMDD10.);&lt;/P&gt;&lt;P&gt;format mortality YYMMDD10.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;But it failed and provides values for example 2002-07-23 which is incorrect. The data is from year 2016 and 2017.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 17:56:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-numeric-to-date-format-in-SAS/m-p/870411#M343789</guid>
      <dc:creator>WishShahid</dc:creator>
      <dc:date>2023-04-18T17:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a numeric to date format in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-numeric-to-date-format-in-SAS/m-p/870413#M343790</link>
      <description>&lt;P&gt;May I ask what date 20984 represents? It may be that it is supposed to represent 14JUN2017. If so, there is no need to "convert" it to anything, and you certainly cannot convert it to have a specific format, that would be an incorrect use of the language.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All you have to do is assign the proper format to the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testdata1;
    set testdata;
    format deathdate yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or use any other date format you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Better yet&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets library=work;
    modify testdata;
    format deathdate yymmdd10.;
run; quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and now you don't have to read every row in the entire data set just to assign a format to one variable.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 18:03:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-numeric-to-date-format-in-SAS/m-p/870413#M343790</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-18T18:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a numeric to date format in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-numeric-to-date-format-in-SAS/m-p/870420#M343791</link>
      <description>&lt;P&gt;Thank you for your response! Yes&lt;SPAN&gt;&amp;nbsp;date 20984 represents 14JUN2017. I am a new user of sas. I would like to export this SAS file to SPSS. I have attempted to export into SPSS or excel where I do not get equivalent values in date format.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 18:26:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-numeric-to-date-format-in-SAS/m-p/870420#M343791</guid>
      <dc:creator>WishShahid</dc:creator>
      <dc:date>2023-04-18T18:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a numeric to date format in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-numeric-to-date-format-in-SAS/m-p/870424#M343792</link>
      <description>&lt;P&gt;Your SPSS question probably belongs in a new thread with appropriate subject line. Or better yet, ask in an SPSS forum.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 18:34:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-numeric-to-date-format-in-SAS/m-p/870424#M343792</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-18T18:34:36Z</dc:date>
    </item>
  </channel>
</rss>

