<?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/500692#M133374</link>
    <description>&lt;P&gt;Please post test data in the form of a datastep of exactly what you have, and then show from that test data what you want out.&amp;nbsp; You are talking about several different things, first you say its yyyy.mm.dd, now its dd.mm.yyyy?&amp;nbsp; Then you don't seem to understan what the substr function does:&lt;/P&gt;
&lt;P&gt;substr(&amp;lt;string&amp;gt;,&amp;lt;start position&amp;gt;,&amp;lt;number of characters&amp;gt;)&lt;/P&gt;
&lt;P&gt;So in your case from position 10, take 11 characters which gives you this: "&lt;SPAN&gt;28.09.2018&amp;nbsp;", so choosing the right informat:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data want;
  str="28.9.2018 ";
  dte=input(str,ddmmyy10.);
  format dte date9.;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Oct 2018 11:36:56 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-10-02T11:36:56Z</dc:date>
    <item>
      <title>Convert character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/500685#M133369</link>
      <description>&lt;P&gt;Hey&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to SAS, so maybe this is quite easy but i still haven't found a solution. So it goes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a character like: 2018.01.01&lt;/P&gt;&lt;P&gt;(This was a phrase, and i did a&amp;nbsp;SUBSTR to have only the date part)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to convert to date format. When i do: input(char,B8601DA8.) and format&amp;nbsp;PTGDFDD8., nothing happens.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can u help me pls?&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 11:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/500685#M133369</guid>
      <dc:creator>soraiap</dc:creator>
      <dc:date>2018-10-02T11:10:26Z</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/500688#M133371</link>
      <description>&lt;P&gt;Use yymmdd informat:&lt;/P&gt;
&lt;PRE&gt;data want;
  str="2018.01.01";
  dte=input(str,yymmdd10.);
  format dte date9.;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Oct 2018 11:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/500688#M133371</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-02T11:23: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/500689#M133372</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
 x='2018.01.01';
 y=input(x,yymmdd12.);
 format y date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Oct 2018 11:25:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/500689#M133372</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-10-02T11:25:05Z</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/500690#M133373</link>
      <description>&lt;P&gt;i've tried that. the thing is when i did the substring of "via CRM (28.09.2018 / 10:00:00-12:00:00)" to get only the date part i had to do:&lt;BR /&gt;SUBSTR(t1.ATTRIBUTEVALUE, 10, 11)&lt;BR /&gt;&lt;BR /&gt;which is weird, since it has more than two characters, but the result is 28.09.2018.&lt;BR /&gt;&lt;BR /&gt;With that, how do i convert to date?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 11:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/500690#M133373</guid>
      <dc:creator>soraiap</dc:creator>
      <dc:date>2018-10-02T11:32:47Z</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/500692#M133374</link>
      <description>&lt;P&gt;Please post test data in the form of a datastep of exactly what you have, and then show from that test data what you want out.&amp;nbsp; You are talking about several different things, first you say its yyyy.mm.dd, now its dd.mm.yyyy?&amp;nbsp; Then you don't seem to understan what the substr function does:&lt;/P&gt;
&lt;P&gt;substr(&amp;lt;string&amp;gt;,&amp;lt;start position&amp;gt;,&amp;lt;number of characters&amp;gt;)&lt;/P&gt;
&lt;P&gt;So in your case from position 10, take 11 characters which gives you this: "&lt;SPAN&gt;28.09.2018&amp;nbsp;", so choosing the right informat:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data want;
  str="28.9.2018 ";
  dte=input(str,ddmmyy10.);
  format dte date9.;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 11:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/500692#M133374</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-02T11:36:56Z</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/500693#M133375</link>
      <description>&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 11:41:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/500693#M133375</guid>
      <dc:creator>soraiap</dc:creator>
      <dc:date>2018-10-02T11:41:02Z</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/578497#M164086</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a same question with dates. I have a character value for date of birth&amp;nbsp; which is 36223 and I want to convert it to any date format either date9 or yymmdd or mmddyy. My excel shows that date as 3/5/1999 but when I converted to sas date using date9 or any other formats it gives me 3/4/2059 which is very weird.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my program that I wrote to convert it to sas date format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;set new;&lt;/P&gt;&lt;P&gt;birthdate=input(dob, yymmdd10.);&lt;/P&gt;&lt;P&gt;format birthdate date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting many missing values for other DOBs but some date of births that I get are not correct. As I mentioned above the character value of 36223 comes as 3/4/2059 after applying the format. Any help is greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;M&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 16:20:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-date/m-p/578497#M164086</guid>
      <dc:creator>Malathi13</dc:creator>
      <dc:date>2019-08-01T16:20:54Z</dc:date>
    </item>
  </channel>
</rss>

