<?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: Character to Date Format in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-Date-Format/m-p/744622#M80633</link>
    <description>&lt;P&gt;I would be careful about the ANYDTDTE informat. The output depends on the DATESTYLE option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         options datestyle=dmy;
 74         data _null_;
 75         infile datalines;
 76         input origdate $10.;
 77         newdate=input(origdate,anydtdte10.);
 78         put newdate date9.;
 79         datalines;
 
 01MAY2010
 24DEC2013
 10MAR2012
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 83         ;
 84         run;
 85         
 86         options datestyle=mdy;
 87         data _null_;
 88         infile datalines;
 89         input origdate $10.;
 90         newdate=input(origdate,anydtdte10.);
 91         put newdate date9.;
 92         datalines;
 
 05JAN2010
 24DEC2013
 03OCT2012
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So your program gets different results depending on the environment you are running in, as the default for DATETIME depends on the LOCALE option.&lt;/P&gt;</description>
    <pubDate>Sat, 29 May 2021 17:21:25 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2021-05-29T17:21:25Z</dc:date>
    <item>
      <title>Character to Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-Date-Format/m-p/743880#M80610</link>
      <description>&lt;P&gt;I have a date variable in character format, length 10, format and informat $10. Examples of the values are 1/5/2010, 12/24/2013, 10/3/2012 (note that month and day do NOT have leading zeros). I would like to convert this variable to date format, but can't seem to find an informat that will work with this. I'm guessing I need to do something like the following.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;new_date = input(orig_date, [informat]);&lt;/PRE&gt;
&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 14:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-Date-Format/m-p/743880#M80610</guid>
      <dc:creator>raivester</dc:creator>
      <dc:date>2021-05-26T14:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Character to Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-Date-Format/m-p/743883#M80611</link>
      <description>&lt;P&gt;Sure, just use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_date = input(orig_date, mmddyy10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS is bright enough to figure it out.&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 14:05:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-Date-Format/m-p/743883#M80611</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-05-26T14:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Character to Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-Date-Format/m-p/743885#M80612</link>
      <description>&lt;P&gt;data test;&lt;BR /&gt;infile datalines;&lt;BR /&gt;input origdate $10.;&lt;/P&gt;
&lt;P&gt;newdate=input(origdate,anydtdte10.);&lt;BR /&gt;datalines;&lt;BR /&gt;1/5/2010&lt;BR /&gt;12/24/2013&lt;BR /&gt;10/3/2012&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 14:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-Date-Format/m-p/743885#M80612</guid>
      <dc:creator>CarmineVerrell</dc:creator>
      <dc:date>2021-05-26T14:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Character to Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-Date-Format/m-p/743887#M80613</link>
      <description>&lt;P&gt;Assuming the other two examples are like the second one then you want to treat the values as MDY.&amp;nbsp; So use the MMDDYY informat.&amp;nbsp; Note that the INPUT() function does not care if you use a width on the informat that is longer than the length of string you are reading.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_date = input(orig_date, mmddyy10.);
format new_date yymmdd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note I would not use either MDY or DMY order to display the dates to avoid confusing half of your audience.&amp;nbsp; So either use DATE or YYMMDD as the format to attach to the new variable.&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 14:11:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-Date-Format/m-p/743887#M80613</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-26T14:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Character to Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-Date-Format/m-p/744622#M80633</link>
      <description>&lt;P&gt;I would be careful about the ANYDTDTE informat. The output depends on the DATESTYLE option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         options datestyle=dmy;
 74         data _null_;
 75         infile datalines;
 76         input origdate $10.;
 77         newdate=input(origdate,anydtdte10.);
 78         put newdate date9.;
 79         datalines;
 
 01MAY2010
 24DEC2013
 10MAR2012
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 83         ;
 84         run;
 85         
 86         options datestyle=mdy;
 87         data _null_;
 88         infile datalines;
 89         input origdate $10.;
 90         newdate=input(origdate,anydtdte10.);
 91         put newdate date9.;
 92         datalines;
 
 05JAN2010
 24DEC2013
 03OCT2012
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So your program gets different results depending on the environment you are running in, as the default for DATETIME depends on the LOCALE option.&lt;/P&gt;</description>
      <pubDate>Sat, 29 May 2021 17:21:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-Date-Format/m-p/744622#M80633</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2021-05-29T17:21:25Z</dc:date>
    </item>
  </channel>
</rss>

