<?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: converting character date to date9. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736583#M229493</link>
    <description>&lt;P&gt;Tell the INPUT() function to use the full length of the string instead of truncating at 9 characters.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input char_date $11.;
cards;
22 DEC 2020
2 FEB 2021
;

data want;
  set have;
  date = input(char_date,date11.);
  format date date9. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs     char_date          date

 1     22 DEC 2020    22DEC2020
 2     2 FEB 2021     02FEB2021

&lt;/PRE&gt;</description>
    <pubDate>Fri, 23 Apr 2021 13:05:11 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-04-23T13:05:11Z</dc:date>
    <item>
      <title>converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736563#M229477</link>
      <description>&lt;P&gt;I have character dates and converting them to num date9. but fails to work for char date which is like "2 FEB 2021".&lt;/P&gt;
&lt;P&gt;char_date&lt;/P&gt;
&lt;P&gt;22 DEC 2020&lt;BR /&gt;2 FEB 2021&lt;/P&gt;
&lt;P&gt;i use the below step and it works for first record but doesnt work for second one.&lt;/P&gt;
&lt;P&gt;ADT=input(char_date, date9.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do i get 0 in case day is single digit.&lt;/P&gt;
&lt;P&gt;Any clue please&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 09:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736563#M229477</guid>
      <dc:creator>noda6003</dc:creator>
      <dc:date>2021-04-23T09:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736565#M229479</link>
      <description>&lt;P&gt;For example, if you do this and remove the spaces, it will be recognized.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  ADT=input(compress(char_date), date9.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Apr 2021 09:37:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736565#M229479</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-04-23T09:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736566#M229480</link>
      <description>&lt;P&gt;No, unfortunately it didnt work&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 09:43:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736566#M229480</guid>
      <dc:creator>noda6003</dc:creator>
      <dc:date>2021-04-23T09:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736567#M229481</link>
      <description>&lt;P&gt;can you provide data that can be reproduced using datalines in the data step?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 09:47:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736567#M229481</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-04-23T09:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736569#M229482</link>
      <description>&lt;P&gt;To get a leading zero, either use a custom format for DATE9, or use another standard format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input char_date $20.;
datalines;
22 DEC 2020
2 FEB 2021
;

proc format;
picture mydate
  other='%0d%b%Y' (datatype=date language=english)
;
run;
  
data want;
set have;
num_date = input(compress(char_date),date9.);
format num_date mydate9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
num_date = input(compress(char_date),date9.);
format num_date yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 10:09:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736569#M229482</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-23T10:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736579#M229490</link>
      <description>&lt;PRE&gt;data want;
set have;
num_date = input(char_date,date11.);
format num_date date9.;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Apr 2021 12:20:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736579#M229490</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-04-23T12:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736583#M229493</link>
      <description>&lt;P&gt;Tell the INPUT() function to use the full length of the string instead of truncating at 9 characters.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input char_date $11.;
cards;
22 DEC 2020
2 FEB 2021
;

data want;
  set have;
  date = input(char_date,date11.);
  format date date9. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs     char_date          date

 1     22 DEC 2020    22DEC2020
 2     2 FEB 2021     02FEB2021

&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Apr 2021 13:05:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-date9/m-p/736583#M229493</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-23T13:05:11Z</dc:date>
    </item>
  </channel>
</rss>

