<?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 convert dates to SAS date value in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/convert-dates-to-SAS-date-value/m-p/85339#M24410</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi SAS newbie here&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am importing a excel spreadsheet with 2 date columns (lets say date1 and date2) which are formatted liked this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dd/mm/yyyy and yyyy-mm-dd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS is reading both of these dates like this&lt;/P&gt;&lt;P&gt;01JAN1960&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to convert both of these to SAS data values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So for example 01/01/1960/1960-01-01 would be 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 21 Jul 2013 20:47:28 GMT</pubDate>
    <dc:creator>aivoryuk</dc:creator>
    <dc:date>2013-07-21T20:47:28Z</dc:date>
    <item>
      <title>convert dates to SAS date value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/convert-dates-to-SAS-date-value/m-p/85339#M24410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi SAS newbie here&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am importing a excel spreadsheet with 2 date columns (lets say date1 and date2) which are formatted liked this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dd/mm/yyyy and yyyy-mm-dd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS is reading both of these dates like this&lt;/P&gt;&lt;P&gt;01JAN1960&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to convert both of these to SAS data values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So for example 01/01/1960/1960-01-01 would be 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Jul 2013 20:47:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/convert-dates-to-SAS-date-value/m-p/85339#M24410</guid>
      <dc:creator>aivoryuk</dc:creator>
      <dc:date>2013-07-21T20:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: convert dates to SAS date value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/convert-dates-to-SAS-date-value/m-p/85340#M24411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suspect that you already have the SAS date values, where you are seeing is the Format. I am not going to burden you with some SAS statements/procedures to show the format or remove them, as you said you are 'newbie', here is a simple test to see the TRUE value of your date variables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; set yourtable;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var_test=your_date_var;&lt;/P&gt;&lt;P&gt; put your_date_var= var_test=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the case of 01JAN1960 for your_date_var, you should see the following in your log:&lt;/P&gt;&lt;P&gt;your_date_var=01JAN1960 var_test=0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Jul 2013 21:23:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/convert-dates-to-SAS-date-value/m-p/85340#M24411</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-07-21T21:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: convert dates to SAS date value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/convert-dates-to-SAS-date-value/m-p/85341#M24412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If possible then share your code with us I will modified the the code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jul 2013 04:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/convert-dates-to-SAS-date-value/m-p/85341#M24412</guid>
      <dc:creator>DJChavda</dc:creator>
      <dc:date>2013-07-22T04:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: convert dates to SAS date value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/convert-dates-to-SAS-date-value/m-p/85342#M24413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Given that the date informat and format are different after your import, it is very likely that these dates are already stored as SAS date values but that the format=date9. on your variable turns them into the 01JAN1960 that you are seeing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are different ways to clear out the output format so that you see the actual days count since 01JAN1960. I would use something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc datasets library=work nolist /*or wherever else than work your DS is stored*/;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modify datasetname;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format datevar1 8. datevar2 8.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jul 2013 14:26:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/convert-dates-to-SAS-date-value/m-p/85342#M24413</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-07-22T14:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: convert dates to SAS date value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/convert-dates-to-SAS-date-value/m-p/85343#M24414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks that helped. i managed to put it into a set.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jul 2013 20:42:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/convert-dates-to-SAS-date-value/m-p/85343#M24414</guid>
      <dc:creator>aivoryuk</dc:creator>
      <dc:date>2013-07-22T20:42:39Z</dc:date>
    </item>
  </channel>
</rss>

