<?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/463919#M118253</link>
    <description>&lt;P&gt;The yymmdd10. informat would be used to read data that starts with the year such as 2001/11/20.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may sometimes have to use something like&amp;nbsp; input(strip(variable),&amp;lt;informat&amp;gt;) if the character variable has leading spaces so that the informat starts reading where the data actually begins.&lt;/P&gt;</description>
    <pubDate>Mon, 21 May 2018 22:22:11 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-05-21T22:22:11Z</dc:date>
    <item>
      <title>Convert character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/463601#M118136</link>
      <description>&lt;P&gt;Am not able to convert character text to a SAS date, apologies for the simple request:&lt;/P&gt;&lt;P&gt;Data to be converted are "&lt;SPAN&gt;Mark_App_s" character of length 12.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date sample&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark_App_s&lt;/P&gt;&lt;P&gt;&amp;nbsp;11/20/2001&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;09/05/2017&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;06/06/2017&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;10/31/2017&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code sample is :&lt;/P&gt;&lt;P&gt;Data App_2 ;&lt;BR /&gt;set App_1 ;&lt;BR /&gt;Mark_App = input(Mark_App_s, yymmdd10.) ;&lt;BR /&gt;format Mark_App mmddyy10.;&lt;BR /&gt;run ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks !&lt;/P&gt;</description>
      <pubDate>Sun, 20 May 2018 03:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/463601#M118136</guid>
      <dc:creator>rmacarthur</dc:creator>
      <dc:date>2018-05-20T03:48:43Z</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/463605#M118138</link>
      <description>Change the informat to mmdyy10.:&lt;BR /&gt;&lt;BR /&gt;Mark_App = input(Mark_App_s, mmdyy10.) ;</description>
      <pubDate>Sun, 20 May 2018 04:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/463605#M118138</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-05-20T04:42:09Z</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/463919#M118253</link>
      <description>&lt;P&gt;The yymmdd10. informat would be used to read data that starts with the year such as 2001/11/20.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may sometimes have to use something like&amp;nbsp; input(strip(variable),&amp;lt;informat&amp;gt;) if the character variable has leading spaces so that the informat starts reading where the data actually begins.&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 22:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/463919#M118253</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-21T22:22:11Z</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/463939#M118262</link>
      <description>&lt;P&gt;Thanks, I was using the correct INFOMAT, (mmddyy10.), very sorry I just typed it wrong (above), and I have stripped the leading and trailing characters, and have also set the length of the character variable "&lt;SPAN&gt;Mark_App_s "&amp;nbsp;&lt;/SPAN&gt;to $12.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So here is a data sample:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark_App_s&amp;nbsp;&lt;BR /&gt;&amp;nbsp;11/20/2001&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;09/05/2017&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;08/30/2017&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;06/06/2017&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;10/31/2017&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;01/23/2004&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and here is the code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data App_2 ;&lt;BR /&gt;set&amp;nbsp; &amp;nbsp; App_1 ;&lt;BR /&gt;Mark_App = input(Mark_App_s, mmddyy10.) ;&lt;BR /&gt;format Mark_App mmddyy10.;&lt;BR /&gt;run ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this code does not change the character variable to a date variable.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 00:34:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/463939#M118262</guid>
      <dc:creator>rmacarthur</dc:creator>
      <dc:date>2018-05-22T00:34:17Z</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/463959#M118269</link>
      <description>&lt;P&gt;You can't change type of a variable and there is no a date type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your code Mark_app will be a numeric type. The format defines that it is a date and how to display it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The input variable - Mark_app_s - is a char type variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only way to "change" variable type is by recreating it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have (rename=(numvar=char));
        numvar = input(char, &amp;lt;informat&amp;gt;);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 May 2018 05:43:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/463959#M118269</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-05-22T05:43:07Z</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/467283#M119281</link>
      <description>&lt;P&gt;Note about the solution, the difficulty was caused by hidden characters in the variable "&lt;SPAN&gt;Mark_App_s ", which was imported from an online database.&amp;nbsp; Prior to implementing the above solution, I had to parse the variable using a SUBSTRING into MM, DD, YYYY components, Then tried converting each to a numeric variable.&amp;nbsp; If it would not convert using an INPUT function, that indicated there were hidden characters, and I continued to use the SUBSTRING function until the numeric conversion method worked.&amp;nbsp; Only then could the&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="yiv9528583626msonormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #26282a;"&gt;Mark_App_d&amp;nbsp; =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mdy(Month_2,Day,Year)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="yiv9528583626msonormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="yiv9528583626msonormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #26282a;"&gt;function be used to convert the character variables (&lt;SPAN&gt;Month_2,Day,Year) to a SAS Date.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="yiv9528583626msonormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="yiv9528583626msonormal"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helvetica',sans-serif; color: #26282a;"&gt;Thanks again for your assistance !&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jun 2018 01:35:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/467283#M119281</guid>
      <dc:creator>rmacarthur</dc:creator>
      <dc:date>2018-06-04T01:35:55Z</dc:date>
    </item>
  </channel>
</rss>

