<?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 to turn numeric variable to date format in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-turn-numeric-variable-to-date-format/m-p/883537#M43263</link>
    <description>&lt;P&gt;Hi Sean!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To convert your dates stored as numbers in the "format" DDMMYYYY (DMMYYYY if day is less than 10) to a SAS date, you need to:&lt;/P&gt;&lt;P&gt;1 - convert those numerics to characters, being careful to ensure that a leading 0 "appears" if the day is less than 10 - this can be done with a PUT function, using an adequate format;&lt;/P&gt;&lt;P&gt;2 - convert the resulting characters back to proper dates (stored as numeric) - this can be done with an INPUT function, using a proper informat.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Supposing that the column with the original dates is called &lt;STRONG&gt;numdate&lt;/STRONG&gt;, and the new column with proper date will be called &lt;STRONG&gt;sasdate&lt;/STRONG&gt;, then this is how I would do it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;sasdate = input(put(numdate,z8.),ddmmyy8.)&lt;/PRE&gt;&lt;P&gt;Of course, don't forget to apply a format (e.g. format sasdate ddmmyy10.; ) to the new column in order to make it readable by humans, if that's a requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;José Costa&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jul 2023 11:48:15 GMT</pubDate>
    <dc:creator>José_Costa_biw</dc:creator>
    <dc:date>2023-07-05T11:48:15Z</dc:date>
    <item>
      <title>How to turn numeric variable to date format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-turn-numeric-variable-to-date-format/m-p/883526#M43262</link>
      <description>&lt;P&gt;Morning Folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following type of date which has been created as a number;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;8062023&lt;BR /&gt;12052023&lt;BR /&gt;26052023&lt;BR /&gt;26052023&lt;BR /&gt;6022020&lt;BR /&gt;10042023&lt;BR /&gt;3102017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What would be the best way to turn it into a SAS date variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help welcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sean&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2023 10:05:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-turn-numeric-variable-to-date-format/m-p/883526#M43262</guid>
      <dc:creator>Sean_OConnor</dc:creator>
      <dc:date>2023-07-05T10:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to turn numeric variable to date format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-turn-numeric-variable-to-date-format/m-p/883537#M43263</link>
      <description>&lt;P&gt;Hi Sean!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To convert your dates stored as numbers in the "format" DDMMYYYY (DMMYYYY if day is less than 10) to a SAS date, you need to:&lt;/P&gt;&lt;P&gt;1 - convert those numerics to characters, being careful to ensure that a leading 0 "appears" if the day is less than 10 - this can be done with a PUT function, using an adequate format;&lt;/P&gt;&lt;P&gt;2 - convert the resulting characters back to proper dates (stored as numeric) - this can be done with an INPUT function, using a proper informat.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Supposing that the column with the original dates is called &lt;STRONG&gt;numdate&lt;/STRONG&gt;, and the new column with proper date will be called &lt;STRONG&gt;sasdate&lt;/STRONG&gt;, then this is how I would do it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;sasdate = input(put(numdate,z8.),ddmmyy8.)&lt;/PRE&gt;&lt;P&gt;Of course, don't forget to apply a format (e.g. format sasdate ddmmyy10.; ) to the new column in order to make it readable by humans, if that's a requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;José Costa&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2023 11:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-turn-numeric-variable-to-date-format/m-p/883537#M43263</guid>
      <dc:creator>José_Costa_biw</dc:creator>
      <dc:date>2023-07-05T11:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to turn numeric variable to date format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-turn-numeric-variable-to-date-format/m-p/883611#M43269</link>
      <description>&lt;P&gt;Hi.&amp;nbsp; &amp;nbsp;Try the following.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if this works for you.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;John McCall (SAS Instructor)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* Create a sample table*/&lt;BR /&gt;Data Example_Table;&lt;BR /&gt;Input Date;&lt;BR /&gt;datalines;&lt;BR /&gt;8062023&lt;BR /&gt;12052023&lt;BR /&gt;26052023&lt;BR /&gt;26052023&lt;BR /&gt;6022020&lt;BR /&gt;10042023&lt;BR /&gt;3102017&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;/* Change numbers to SAS dates*/&lt;BR /&gt;Data Convert_to_SASDate;&lt;BR /&gt;set example_table(rename=(date=Original_Date));&lt;BR /&gt;Date=Input(put(original_Date,10.),ddmmyy10.);&lt;BR /&gt;format date mmddyy10.;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=Convert_to_SASDate;&lt;BR /&gt;title "Does this conversion work for you?";&lt;BR /&gt;run;&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;
&lt;TABLE class="systitleandfootercontainer" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="c systemtitle"&gt;Does this conversion work for you?&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.COVERT_TO_SASDATE" frame="box" rules="groups" cellspacing="1" cellpadding="7"&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Original_Date&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Date&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="r data"&gt;8062023&lt;/TD&gt;
&lt;TD class="r data"&gt;06/08/2023&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="r data"&gt;12052023&lt;/TD&gt;
&lt;TD class="r data"&gt;05/12/2023&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;3&lt;/TH&gt;
&lt;TD class="r data"&gt;26052023&lt;/TD&gt;
&lt;TD class="r data"&gt;05/26/2023&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;4&lt;/TH&gt;
&lt;TD class="r data"&gt;26052023&lt;/TD&gt;
&lt;TD class="r data"&gt;05/26/2023&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;5&lt;/TH&gt;
&lt;TD class="r data"&gt;6022020&lt;/TD&gt;
&lt;TD class="r data"&gt;02/06/2020&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;6&lt;/TH&gt;
&lt;TD class="r data"&gt;10042023&lt;/TD&gt;
&lt;TD class="r data"&gt;04/10/2023&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;7&lt;/TH&gt;
&lt;TD class="r data"&gt;3102017&lt;/TD&gt;
&lt;TD class="r data"&gt;10/03/2017&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 05 Jul 2023 17:44:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-turn-numeric-variable-to-date-format/m-p/883611#M43269</guid>
      <dc:creator>john_mccall</dc:creator>
      <dc:date>2023-07-05T17:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to turn numeric variable to date format</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-turn-numeric-variable-to-date-format/m-p/883612#M43270</link>
      <description>Hi.  I just realized my answer is similar to Jose's excellent response.  &lt;BR /&gt;Best.</description>
      <pubDate>Wed, 05 Jul 2023 17:54:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-turn-numeric-variable-to-date-format/m-p/883612#M43270</guid>
      <dc:creator>john_mccall</dc:creator>
      <dc:date>2023-07-05T17:54:45Z</dc:date>
    </item>
  </channel>
</rss>

