<?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 Converting character field to date field in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486837#M126728</link>
    <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;I'm having trouble to convert the following character field to date field with the SAS code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data temp1;&lt;BR /&gt;length id $1. date $10.;&lt;BR /&gt;infile DATALINES dsd missover;&lt;BR /&gt;input id date $;&lt;BR /&gt;CARDS;&lt;BR /&gt;1, 7/ 3/2011&lt;BR /&gt;2, 3/17/2011&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data temp2;&lt;BR /&gt;set temp1;&lt;/P&gt;&lt;P&gt;new_date=input(date, mmddyy10.); format new_date date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code works for the second record (&lt;SPAN&gt;3/17/2011&lt;/SPAN&gt;) but not for the first one (&lt;SPAN&gt;7/ 3/2011&lt;/SPAN&gt;). I think the reason for that is the way the &lt;U&gt;&lt;STRONG&gt;day&lt;/STRONG&gt;&lt;/U&gt; part of the field was recorded in the second record. As you can notice there is a blank space between "/" and "3".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if there is another SAS date format to be able to tackle this issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Recep&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: I use SAS 9.4 TS Level 1M3 on W32 7Pro platform.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Aug 2018 20:59:18 GMT</pubDate>
    <dc:creator>Recep</dc:creator>
    <dc:date>2018-08-14T20:59:18Z</dc:date>
    <item>
      <title>Converting character field to date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486837#M126728</link>
      <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;I'm having trouble to convert the following character field to date field with the SAS code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data temp1;&lt;BR /&gt;length id $1. date $10.;&lt;BR /&gt;infile DATALINES dsd missover;&lt;BR /&gt;input id date $;&lt;BR /&gt;CARDS;&lt;BR /&gt;1, 7/ 3/2011&lt;BR /&gt;2, 3/17/2011&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data temp2;&lt;BR /&gt;set temp1;&lt;/P&gt;&lt;P&gt;new_date=input(date, mmddyy10.); format new_date date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code works for the second record (&lt;SPAN&gt;3/17/2011&lt;/SPAN&gt;) but not for the first one (&lt;SPAN&gt;7/ 3/2011&lt;/SPAN&gt;). I think the reason for that is the way the &lt;U&gt;&lt;STRONG&gt;day&lt;/STRONG&gt;&lt;/U&gt; part of the field was recorded in the second record. As you can notice there is a blank space between "/" and "3".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if there is another SAS date format to be able to tackle this issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Recep&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: I use SAS 9.4 TS Level 1M3 on W32 7Pro platform.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 20:59:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486837#M126728</guid>
      <dc:creator>Recep</dc:creator>
      <dc:date>2018-08-14T20:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character field to date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486840#M126729</link>
      <description>&lt;P&gt;Try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;informat date mmddyy10.;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp1;
length id $1. date 8.;
informat date mmddyy10.;
infile DATALINES dsd truncover;
input id date ;
CARDS;
1, 7/ 3/2011
2, 3/17/2011
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Aug 2018 21:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486840#M126729</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-14T21:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character field to date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486846#M126730</link>
      <description>&lt;P&gt;Hi Reza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for your response! Unfortunately the code did not work. Plus I was hoping to deal with the problem with a SAS date format as opposed to reading raw data into SAS. The data I have already exist as a SAS file and I would like to manipulate the character date field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Recep&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 21:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486846#M126730</guid>
      <dc:creator>Recep</dc:creator>
      <dc:date>2018-08-14T21:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character field to date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486847#M126731</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122505"&gt;@Recep&lt;/a&gt;&amp;nbsp;I have had that issue before. if you know your char date values are inconsistent of that type, use compress&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data temp1;
length id $1. date $10.;
infile DATALINES dsd missover;
input id date $;
CARDS;
1, 7/ 3/2011
2, 3/17/2011
;
run;

 

data temp2;
set temp1;
new_date=input(compress(date), mmddyy10.); format new_date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Aug 2018 21:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486847#M126731</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-08-14T21:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character field to date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486851#M126732</link>
      <description>&lt;P&gt;new_var = input(variable, mmddyy10.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122505"&gt;@Recep&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Reza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot for your response! Unfortunately the code did not work. Plus I was hoping to deal with the problem with a SAS date format as opposed to reading raw data into SAS. The data I have already exist as a SAS file and I would like to manipulate the character date field.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Recep&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 21:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486851#M126732</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-14T21:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character field to date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486854#M126733</link>
      <description>&lt;P&gt;Thanks a lot! This is exactly what I needed to...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Recep&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 21:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486854#M126733</guid>
      <dc:creator>Recep</dc:creator>
      <dc:date>2018-08-14T21:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character field to date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486855#M126734</link>
      <description>&lt;P&gt;I think you meant to mark&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;post as correct because mine clearly isn't....:(&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 21:48:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486855#M126734</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-14T21:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character field to date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486856#M126735</link>
      <description>&lt;P&gt;Thanks a lot for letting me know Reeza! Clearly it's getting late here:)&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 21:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-field-to-date-field/m-p/486856#M126735</guid>
      <dc:creator>Recep</dc:creator>
      <dc:date>2018-08-14T21:51:24Z</dc:date>
    </item>
  </channel>
</rss>

