<?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 to date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843861#M333612</link>
    <description>&lt;P&gt;Read the documentation on the format you used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="xis-syntaxSimple"&gt;
&lt;DIV class="xis-syntaxLevel"&gt;&lt;SPAN class="xis-keyword"&gt;ANYDTDTE&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/leforinforref/1.0/n04jh1fkv5c8zan14fhqcby7jsu4.htm#n1hz8r2fcbvw2qn1ui4b8x7cy14z" target="_blank"&gt;w&lt;/A&gt;&lt;/SPAN&gt;.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="xis-syntaxDescription"&gt;
&lt;DIV class="xis-otherArgGroup"&gt;
&lt;H3 class="xis-title"&gt;Syntax Description&lt;/H3&gt;
&lt;DIV id="n1hz8r2fcbvw2qn1ui4b8x7cy14z" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;w&lt;/SPAN&gt;&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;specifies the width of the input field.&lt;/P&gt;
&lt;TABLE class="xis-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xis-summaryDefault"&gt;Default&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-summaryRange"&gt;Range&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;5–32&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't tell it what WIDTH (how many characters to read) then it uses the DEFAULT width.&lt;/P&gt;
&lt;P&gt;In this case the default is 9 characters.&amp;nbsp; So for that value it read&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;2022-10-2&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general you should only use a guessing procedure, like the ANYDT... series of informats, when the format of the strings is unknown.&amp;nbsp; But your provided example were all using 10 characters in YYYY-MM-DD to record the date part of the string.&amp;nbsp; So use the YYMMDD10. informat .&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Fri, 11 Nov 2022 21:17:30 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-11-11T21:17:30Z</dc:date>
    <item>
      <title>Convert Character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843845#M333604</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone help with converting a character to date? I just need MMDDYY thanks a lot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below is the sample data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="316px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;FundedDate&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-11-02 12:32:48.4126877 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-10-22 18:16:32.7534728 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-10-12 10:45:02.4220416 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-10-06 14:58:36.9955507 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-10-04 11:01:24.8600005 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-10-15 18:11:57.0140644 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-11-02 12:32:48.4126877 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-10-22 18:16:32.7534728 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-10-12 10:45:02.4220416 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-10-06 14:58:36.9955507 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-10-04 11:01:24.8600005 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-10-15 18:11:57.0140644 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-10-19 19:18:16.7061785 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-11-07 11:08:37.9587636 -05:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-10-21 15:58:18.4112167 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-10-31 16:33:16.2012582 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="314.878px"&gt;2022-10-23 17:18:36.6695760 -04:00&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 11 Nov 2022 19:29:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843845#M333604</guid>
      <dc:creator>Eugenio211</dc:creator>
      <dc:date>2022-11-11T19:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843846#M333605</link>
      <description>&lt;P&gt;Extract the first 10 characters (SUBSTR) and convert them to a date with the INPUT function, using the YYMMDD10. informat.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 19:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843846#M333605</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-11T19:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843847#M333606</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input FundedDate $ 1 - 35;
datalines;
2022-11-02 12:32:48.4126877 -04:00
2022-10-22 18:16:32.7534728 -04:00
2022-10-12 10:45:02.4220416 -04:00
2022-10-06 14:58:36.9955507 -04:00
2022-10-04 11:01:24.8600005 -04:00
2022-10-15 18:11:57.0140644 -04:00
2022-11-02 12:32:48.4126877 -04:00
2022-10-22 18:16:32.7534728 -04:00
2022-10-12 10:45:02.4220416 -04:00
2022-10-06 14:58:36.9955507 -04:00
2022-10-04 11:01:24.8600005 -04:00
2022-10-15 18:11:57.0140644 -04:00
2022-10-19 19:18:16.7061785 -04:00
2022-11-07 11:08:37.9587636 -05:00
2022-10-21 15:58:18.4112167 -04:00
2022-10-31 16:33:16.2012582 -04:00
2022-10-23 17:18:36.6695760 -04:00
;

data want;
   set have;
   dt = input(substr(FundedDate, 1, 10), yymmdd10.);
   format dt mmddyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Nov 2022 19:33:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843847#M333606</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-11-11T19:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843848#M333607</link>
      <description>&lt;P&gt;Just use INPUT() function with the YYMMDD10. informat.&lt;/P&gt;
&lt;P&gt;You can then attach any date type format you want to the new numeric variable.&amp;nbsp; But I would not recommend using MMDDYY because whether you display dates in Month-Day order or Day-Month order it will confuse half of your audience.&amp;nbsp; So use either YYMMDD or DATE to avoid confusion.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  actualdate = input(fundeddate,yymmdd10.);
  format actualdate yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 19:43:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843848#M333607</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-11T19:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843849#M333608</link>
      <description>&lt;P&gt;Hi - I used the substr function to extract the date and format it, however i got the worng date after formatting, any idea?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example&lt;/P&gt;
&lt;P&gt;Character Date =&amp;nbsp;2022-10-22 18:16:32.7534728 -04:00&lt;/P&gt;
&lt;P&gt;Substr =&amp;nbsp;2022-10-22&lt;/P&gt;
&lt;P&gt;after format =&amp;nbsp;10/02/22&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is my data step&lt;/P&gt;
&lt;P&gt;data LOC_List1; set LOC_List;&lt;BR /&gt;Funded_Dt = substr(FundedDate,1,10);&lt;BR /&gt;FundedDt = input(Funded_Dt,anydtdte.);&lt;BR /&gt;format FundedDt mmddyy.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 19:49:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843849#M333608</guid>
      <dc:creator>Eugenio211</dc:creator>
      <dc:date>2022-11-11T19:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843850#M333609</link>
      <description>&lt;P&gt;Please reread the thread. NOBODY told you to use the ANYDTDTE informat. We all advised you to use YYMMDD10.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 19:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843850#M333609</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-11T19:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843861#M333612</link>
      <description>&lt;P&gt;Read the documentation on the format you used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="xis-syntaxSimple"&gt;
&lt;DIV class="xis-syntaxLevel"&gt;&lt;SPAN class="xis-keyword"&gt;ANYDTDTE&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/leforinforref/1.0/n04jh1fkv5c8zan14fhqcby7jsu4.htm#n1hz8r2fcbvw2qn1ui4b8x7cy14z" target="_blank"&gt;w&lt;/A&gt;&lt;/SPAN&gt;.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="xis-syntaxDescription"&gt;
&lt;DIV class="xis-otherArgGroup"&gt;
&lt;H3 class="xis-title"&gt;Syntax Description&lt;/H3&gt;
&lt;DIV id="n1hz8r2fcbvw2qn1ui4b8x7cy14z" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;w&lt;/SPAN&gt;&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;specifies the width of the input field.&lt;/P&gt;
&lt;TABLE class="xis-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xis-summaryDefault"&gt;Default&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-summaryRange"&gt;Range&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;5–32&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't tell it what WIDTH (how many characters to read) then it uses the DEFAULT width.&lt;/P&gt;
&lt;P&gt;In this case the default is 9 characters.&amp;nbsp; So for that value it read&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;2022-10-2&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general you should only use a guessing procedure, like the ANYDT... series of informats, when the format of the strings is unknown.&amp;nbsp; But your provided example were all using 10 characters in YYYY-MM-DD to record the date part of the string.&amp;nbsp; So use the YYMMDD10. informat .&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 11 Nov 2022 21:17:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Character-to-date/m-p/843861#M333612</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-11T21:17:30Z</dc:date>
    </item>
  </channel>
</rss>

