<?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 to Convert a Character Variable to MMDDYYYY Date? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Convert-a-Character-Variable-to-MMDDYYYY-Date/m-p/802698#M316021</link>
    <description>&lt;P&gt;One creating a new variable with an INPUT statement and assign appropriate format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   x="2021-01-01" ;
   y= input(x,yymmdd10.);
   format y mmddyyn8.;
run;&lt;/PRE&gt;
&lt;P&gt;There are a large number of SAS supplied date formats and you can roll your own with Proc Format for date values if you can't find one you like/want. the N in the MMDDYYN is to indicate "no separator" between month, day and year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to guess that you want Month first as your shown example of 01012021 does not clearer indicate if the first position is a month or day value. If by chance you want day first there is a similar DDMMYYN format available.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Mar 2022 20:03:34 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-03-17T20:03:34Z</dc:date>
    <item>
      <title>How to Convert a Character Variable to MMDDYYYY Date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Convert-a-Character-Variable-to-MMDDYYYY-Date/m-p/802695#M316018</link>
      <description>&lt;P&gt;I have variable, test date, that is written as "2021-01-01" and was formatted as a character variable in the file I have. How can I format it to be a date variable, 01012021?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 19:55:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Convert-a-Character-Variable-to-MMDDYYYY-Date/m-p/802695#M316018</guid>
      <dc:creator>SAS_learneromg</dc:creator>
      <dc:date>2022-03-17T19:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to Convert a Character Variable to MMDDYYYY Date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Convert-a-Character-Variable-to-MMDDYYYY-Date/m-p/802698#M316021</link>
      <description>&lt;P&gt;One creating a new variable with an INPUT statement and assign appropriate format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   x="2021-01-01" ;
   y= input(x,yymmdd10.);
   format y mmddyyn8.;
run;&lt;/PRE&gt;
&lt;P&gt;There are a large number of SAS supplied date formats and you can roll your own with Proc Format for date values if you can't find one you like/want. the N in the MMDDYYN is to indicate "no separator" between month, day and year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to guess that you want Month first as your shown example of 01012021 does not clearer indicate if the first position is a month or day value. If by chance you want day first there is a similar DDMMYYN format available.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 20:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Convert-a-Character-Variable-to-MMDDYYYY-Date/m-p/802698#M316021</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-17T20:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to Convert a Character Variable to MMDDYYYY Date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Convert-a-Character-Variable-to-MMDDYYYY-Date/m-p/802700#M316023</link>
      <description>&lt;P&gt;A FORMAT in SAS is instructions for how to display values as text.&amp;nbsp; There is no FORMAT that will display a character string as a date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use an INPUT() function with an INFORMAT (informats are instructions for converting&amp;nbsp; text into values) to make a new variable that has a date value.&amp;nbsp; You could then attach a format to that to have it print in the style you want.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;actual_date=input('test date'n,yymmdd10.);
format actual_date mmddyyn8. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you would rather replace the text string in your 'test date'n variable then you could use the PUT() function with the MMDDYYn8. format to to store a string in MMDDYYYY style back into the original character variable.&amp;nbsp; But it wouldn't be a date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 20:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Convert-a-Character-Variable-to-MMDDYYYY-Date/m-p/802700#M316023</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-17T20:26:14Z</dc:date>
    </item>
  </channel>
</rss>

