<?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: Converting Char value in File system into a Date9. format in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-Char-value-in-File-system-into-a-Date9-format/m-p/123279#M1554</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You say your requirement is for a numeric date variable but you are using the PUT() function, which always returns a character value.&amp;nbsp; Use the INPUT() function.&amp;nbsp; You do not need the datepart function if your starting value is already a character value as defined.&amp;nbsp; The Date9 &lt;EM&gt;informat&lt;/EM&gt; used in the INPUT() function will only read the first 9 characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You also say you want the date to appear in Date9 format:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Format Birth_date date9. ;&lt;/P&gt;&lt;P&gt;Birth_date = input(DOB, date9.) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard in Oz&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 11 Nov 2012 10:04:16 GMT</pubDate>
    <dc:creator>RichardinOz</dc:creator>
    <dc:date>2012-11-11T10:04:16Z</dc:date>
    <item>
      <title>Converting Char value in File system into a Date9. format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-Char-value-in-File-system-into-a-Date9-format/m-p/123277#M1552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am importing a .txt file which has a column name date of birth in the format 06JUN2012:10:32:13. In the file system its in Char format and now i want to change the vale to numeric date9. .i.e. 06JAUN2012. In the expression window ( File reader), i used put(datepart(DOB),DATE9.) but some how its not working.&lt;/P&gt;&lt;P&gt;Is am missing anything here? Please help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 11 Nov 2012 06:21:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Converting-Char-value-in-File-system-into-a-Date9-format/m-p/123277#M1552</guid>
      <dc:creator>AKP</dc:creator>
      <dc:date>2012-11-11T06:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Char value in File system into a Date9. format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-Char-value-in-File-system-into-a-Date9-format/m-p/123278#M1553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In your external file define for DoB INFORMAT as ANYDTDE. and FORMAT as DATE9.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Used together with the File Reader this will result in an input statement using informat ANYDTDTE. to convert the string in source representing a datetime into a SAS date value, and then using format DATE9. to print this SAS date value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This way you don't need any expression in the File Reader.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In general if something is not working when setting up stuff in DI Studio: Look at the code generated and the log produced. This often explains where things are going wrong and gives you the idea of how to fix it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case: DATEPART() converts a SAS datetime value into a SAS date value, PUT then converts this value to a string as defined in the format. So you end up with a character value. What possibly would work: You only use DATEPART() in the expression and you then use DATE9. as format assigned to the variable in the output table (so the green grid after the transformation).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 11 Nov 2012 08:38:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Converting-Char-value-in-File-system-into-a-Date9-format/m-p/123278#M1553</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-11-11T08:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Char value in File system into a Date9. format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-Char-value-in-File-system-into-a-Date9-format/m-p/123279#M1554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You say your requirement is for a numeric date variable but you are using the PUT() function, which always returns a character value.&amp;nbsp; Use the INPUT() function.&amp;nbsp; You do not need the datepart function if your starting value is already a character value as defined.&amp;nbsp; The Date9 &lt;EM&gt;informat&lt;/EM&gt; used in the INPUT() function will only read the first 9 characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You also say you want the date to appear in Date9 format:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Format Birth_date date9. ;&lt;/P&gt;&lt;P&gt;Birth_date = input(DOB, date9.) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard in Oz&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 11 Nov 2012 10:04:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Converting-Char-value-in-File-system-into-a-Date9-format/m-p/123279#M1554</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2012-11-11T10:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Char value in File system into a Date9. format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Converting-Char-value-in-File-system-into-a-Date9-format/m-p/123280#M1555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks it worked.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Nov 2012 05:45:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Converting-Char-value-in-File-system-into-a-Date9-format/m-p/123280#M1555</guid>
      <dc:creator>AKP</dc:creator>
      <dc:date>2012-11-12T05:45:27Z</dc:date>
    </item>
  </channel>
</rss>

