<?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: convert character date to yyyy-mm-dd  date format in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/convert-character-date-to-yyyy-mm-dd-date-format/m-p/520621#M4062</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134228"&gt;@mona4u&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to convert a character date to&amp;nbsp;&amp;nbsp;yyyy-mm-dd data format&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is a sample of the data that I have&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input start_date $;&lt;BR /&gt;datalines;&lt;BR /&gt;15/Nov/2015&lt;BR /&gt;;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please not that SAS documentation is pretty consistent about using MON for abbreviated month names. So your question and title would be better phrased as "convert character date in dd/mon/yyyy format to a date value". Once you have a date value then format used is situational.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Dec 2018 23:28:21 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-12-11T23:28:21Z</dc:date>
    <item>
      <title>convert character date to yyyy-mm-dd  date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/convert-character-date-to-yyyy-mm-dd-date-format/m-p/520612#M4060</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to convert a character date to&amp;nbsp;&amp;nbsp;yyyy-mm-dd data format&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is a sample of the data that I have&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input start_date $;&lt;BR /&gt;datalines;&lt;BR /&gt;15/Nov/2015&lt;BR /&gt;;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 22:49:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/convert-character-date-to-yyyy-mm-dd-date-format/m-p/520612#M4060</guid>
      <dc:creator>mona4u</dc:creator>
      <dc:date>2018-12-11T22:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: convert character date to yyyy-mm-dd  date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/convert-character-date-to-yyyy-mm-dd-date-format/m-p/520615#M4061</link>
      <description>COMPRESS() to remove the / and INPUT() with DATE9 to read it in. &lt;BR /&gt;&lt;BR /&gt;want = input(compress(start_date, '/'), date9.);</description>
      <pubDate>Tue, 11 Dec 2018 22:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/convert-character-date-to-yyyy-mm-dd-date-format/m-p/520615#M4061</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-11T22:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: convert character date to yyyy-mm-dd  date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/convert-character-date-to-yyyy-mm-dd-date-format/m-p/520621#M4062</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134228"&gt;@mona4u&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to convert a character date to&amp;nbsp;&amp;nbsp;yyyy-mm-dd data format&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is a sample of the data that I have&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input start_date $;&lt;BR /&gt;datalines;&lt;BR /&gt;15/Nov/2015&lt;BR /&gt;;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please not that SAS documentation is pretty consistent about using MON for abbreviated month names. So your question and title would be better phrased as "convert character date in dd/mon/yyyy format to a date value". Once you have a date value then format used is situational.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 23:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/convert-character-date-to-yyyy-mm-dd-date-format/m-p/520621#M4062</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-11T23:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: convert character date to yyyy-mm-dd  date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/convert-character-date-to-yyyy-mm-dd-date-format/m-p/520699#M4073</link>
      <description>&lt;P&gt;First of all: testing of code is not a crime, but a necessity.&lt;/P&gt;
&lt;P&gt;If you run your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input start_date $;
datalines;
15/Nov/2015
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and look at the resulting dataset, you will find that the character date has been truncated to 8 characters. This is because you did not explicitly set a length (Maxim 47) and SAS therefore defaulted to 8.&lt;/P&gt;
&lt;P&gt;With a very slight change, the code works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input start_date :$11.;
datalines;
15/Nov/2015
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;By simply changing the informat to a date format, and assigning the wanted display format, you will achieve what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input start_date :date11.;
format start_date yymmddd10.;
datalines;
15/Nov/2015
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or by running the following conversion step on your original data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input start_date :$11.;
datalines;
15/Nov/2015
;
run;

data want;
set have (rename=(start_date=_start_date));
start_date = input(_start_date,date11.);
format start_date yymmddd10.;
drop _start_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Dec 2018 08:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/convert-character-date-to-yyyy-mm-dd-date-format/m-p/520699#M4073</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-12T08:01:48Z</dc:date>
    </item>
  </channel>
</rss>

