<?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 do I convert from char dd-mm-yyyy to DATE9? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-from-char-dd-mm-yyyy-to-DATE9/m-p/529546#M144708</link>
    <description>&lt;P&gt;I was given a SAS data file and there was no importing (excel, etc.). The image in my question was from the output data. I'm not sure what the numbers mean in the date_start2 column as well. And I'm not sure why the dates are truncated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture1.PNG" style="width: 188px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26522i68A9CE39824E73C5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture1.PNG" alt="Capture1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this picture, I imported these dates from an excel I quickly made to try examples. It seems to be working then.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jan 2019 20:58:35 GMT</pubDate>
    <dc:creator>shril_21</dc:creator>
    <dc:date>2019-01-23T20:58:35Z</dc:date>
    <item>
      <title>How do I convert from char dd-mm-yyyy to DATE9?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-from-char-dd-mm-yyyy-to-DATE9/m-p/529528#M144700</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS enterprise guide 7.1 and I need help in converting dates in one of my columns to date9 format. I have a column with the name "date_start" with dates as strings.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;date_start:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;21-02-2016 --&amp;gt; 21FEB2016&lt;/P&gt;&lt;P&gt;17-12-2015&lt;/P&gt;&lt;P&gt;23-02-2016&lt;/P&gt;&lt;P&gt;08-05-2016&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are all strings and I would like to convert them to DATE9 format. Here is my code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new4;

set &amp;lt;file I'm working with&amp;gt;;

new_var = input(date_start, ddmmyy10.);
format new_var date09.;&lt;BR /&gt;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This image is after running the program. The last digit of the year is cut off and date_start2 does not have the DATE9. format.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 187px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26520i2E2D891246003663/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you for considering my question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 20:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-from-char-dd-mm-yyyy-to-DATE9/m-p/529528#M144700</guid>
      <dc:creator>shril_21</dc:creator>
      <dc:date>2019-01-23T20:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert from char dd-mm-yyyy to DATE9?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-from-char-dd-mm-yyyy-to-DATE9/m-p/529532#M144702</link>
      <description>The format is date9, not date09.</description>
      <pubDate>Wed, 23 Jan 2019 20:43:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-from-char-dd-mm-yyyy-to-DATE9/m-p/529532#M144702</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-23T20:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert from char dd-mm-yyyy to DATE9?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-from-char-dd-mm-yyyy-to-DATE9/m-p/529536#M144704</link>
      <description>&lt;P&gt;Your character dates appear truncated, note that you have no last digits for any of the years.&amp;nbsp; Did you read these from a file?&lt;/P&gt;
&lt;P&gt;If so, the import process appears incorrect.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It could be a display issue, but otherwise, your code should actually work, including the date09 portion.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256982"&gt;@shril_21&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using SAS enterprise guide 7.1 and I need help in converting dates in one of my columns to date9 format. I have a column with the name "date_start" with dates as strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date_start:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;21-02-2016 --&amp;gt; 21FEB2016&lt;/P&gt;
&lt;P&gt;17-12-2015&lt;/P&gt;
&lt;P&gt;23-02-2016&lt;/P&gt;
&lt;P&gt;08-05-2016&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These are all strings and I would like to convert them to DATE9 format. Here is my code below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new4;

set &amp;lt;file I'm working with&amp;gt;;

new_var = input(date_start, ddmmyy10.);
format new_var date09.;&lt;BR /&gt;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This image is after running the program. The last digit of the year is cut off and date_start2 does not have the DATE9. format.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 187px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26520i2E2D891246003663/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thank you for considering my question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 20:46:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-from-char-dd-mm-yyyy-to-DATE9/m-p/529536#M144704</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-23T20:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert from char dd-mm-yyyy to DATE9?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-from-char-dd-mm-yyyy-to-DATE9/m-p/529546#M144708</link>
      <description>&lt;P&gt;I was given a SAS data file and there was no importing (excel, etc.). The image in my question was from the output data. I'm not sure what the numbers mean in the date_start2 column as well. And I'm not sure why the dates are truncated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture1.PNG" style="width: 188px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26522i68A9CE39824E73C5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture1.PNG" alt="Capture1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this picture, I imported these dates from an excel I quickly made to try examples. It seems to be working then.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 20:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-from-char-dd-mm-yyyy-to-DATE9/m-p/529546#M144708</guid>
      <dc:creator>shril_21</dc:creator>
      <dc:date>2019-01-23T20:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert from char dd-mm-yyyy to DATE9?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-from-char-dd-mm-yyyy-to-DATE9/m-p/529624#M144736</link>
      <description>&lt;P&gt;Your code does not match your presented data (different variable names).&lt;/P&gt;
&lt;P&gt;Your code will work with matching data, see here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input _date_start :$10.;
date_start = input(_date_start,ddmmyy10.);
format date_start date9.;
cards;
21-02-2016
17-12-2015
23-02-2016
08-05-2016
;
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;  _date_          date_
  start           start

21-02-2016    21FEB2016
17-12-2015    17DEC2015
23-02-2016    23FEB2016
08-05-2016    08MAY2016
&lt;/PRE&gt;
&lt;P&gt;If this does not solve your problem, post your log ({i} button), and example data (data step with datalines, see my example and my footnotes).&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 07:19:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-from-char-dd-mm-yyyy-to-DATE9/m-p/529624#M144736</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-01-24T07:19:59Z</dc:date>
    </item>
  </channel>
</rss>

