<?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 DATETIME16. numeric format to  $9 character format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-DATETIME16-numeric-format-to-9-character-format/m-p/620299#M182243</link>
    <description>It takes longer but should definitely stop. Once you have working code, take that from the log and run that next time. It's significantly faster because it can avoid the step of figuring out the data types.</description>
    <pubDate>Mon, 27 Jan 2020 19:33:02 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-01-27T19:33:02Z</dc:date>
    <item>
      <title>convert DATETIME16. numeric format to  $9 character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-DATETIME16-numeric-format-to-9-character-format/m-p/620230#M182215</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data VITALS.vitals_1;
set VITALS.vitals_new;
CodeChar=put(code, datetime16.);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a character variable "Code" in CSV file (eg : 123456-1) which gets automatically converted to&amp;nbsp;DATETIME16. numeric format ( Informat :&amp;nbsp;ANYDTDTM40.;&amp;nbsp; eg 01JUN80:00:00:00) when I try importing the file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please suggest me ways to prevent it while importing or how to convert back the numeric&amp;nbsp;DATETIME16. variable in the imported SAS file to the original $9 character variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using&amp;nbsp; the following code to convert a&amp;nbsp;DATETIME16. numeric format like 01JUN80:00:00:00 to get $9 character format like 8430-6)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data VITALS.vitals_1;&lt;BR /&gt;set VITALS.vitals_new;&lt;BR /&gt;CodeChar=put(code, datetime16.);&lt;/P&gt;&lt;P&gt;*/ "Code" is the&amp;nbsp;numeric&amp;nbsp;DATETIME16. variable which should needs be in character format like 8430-6 */;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 16:49:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-DATETIME16-numeric-format-to-9-character-format/m-p/620230#M182215</guid>
      <dc:creator>Deep_Impact</dc:creator>
      <dc:date>2020-01-27T16:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: convert DATETIME16. numeric format to  $9 character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-DATETIME16-numeric-format-to-9-character-format/m-p/620231#M182216</link>
      <description>&lt;P&gt;Welcome to the SAS Community forums.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For this type of errors you should fix it in the IMPORT process, not after the fact because you cannot assume that SAS parsed it correctly at all.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm assuming you used PROC IMPORT or an IMPORT task to import the data? If so, check the log after, it will have the full code that was used. Take that code and modify the FORMAT/INFORMAT and INPUT statement for the variable in question. Change the format/informat to $9 instead. If you only have a few variables it may be easier to write a data step import yourself.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another option is to add the GUESSINGROWS=MAX to your code to see if it fixes itself but it may not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import out=vitals.vitals_new datafile="path to file" dbms=csv replace;
guessingrows=max;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/309159"&gt;@Deep_Impact&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data VITALS.vitals_1;
set VITALS.vitals_new;
CodeChar=put(code, datetime16.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a character variable "Code" in CSV file (eg : 123456-1) which gets automatically converted to&amp;nbsp;DATETIME16. numeric format ( Informat :&amp;nbsp;ANYDTDTM40.;&amp;nbsp; eg 01JUN80:00:00:00) when I try importing the file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please suggest me ways to prevent it while importing or how to convert back the numeric&amp;nbsp;DATETIME16. variable in the imported SAS file to the original $9 character variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using&amp;nbsp; the following code to convert a&amp;nbsp;DATETIME16. numeric format like 01JUN80:00:00:00 to get $9 character format like 8430-6)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data VITALS.vitals_1;&lt;BR /&gt;set VITALS.vitals_new;&lt;BR /&gt;CodeChar=put(code, datetime16.);&lt;/P&gt;
&lt;P&gt;*/ "Code" is the&amp;nbsp;numeric&amp;nbsp;DATETIME16. variable which should needs be in character format like 8430-6 */;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 16:55:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-DATETIME16-numeric-format-to-9-character-format/m-p/620231#M182216</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-01-27T16:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: convert DATETIME16. numeric format to  $9 character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-DATETIME16-numeric-format-to-9-character-format/m-p/620292#M182237</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;: Thanks for your help; the guessingrows options worked in the proc import stage when I put a number like 100000. The guessingrows=max option was not allowing the datastep to stop.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 19:19:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-DATETIME16-numeric-format-to-9-character-format/m-p/620292#M182237</guid>
      <dc:creator>Deep_Impact</dc:creator>
      <dc:date>2020-01-27T19:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: convert DATETIME16. numeric format to  $9 character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-DATETIME16-numeric-format-to-9-character-format/m-p/620299#M182243</link>
      <description>It takes longer but should definitely stop. Once you have working code, take that from the log and run that next time. It's significantly faster because it can avoid the step of figuring out the data types.</description>
      <pubDate>Mon, 27 Jan 2020 19:33:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-DATETIME16-numeric-format-to-9-character-format/m-p/620299#M182243</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-01-27T19:33:02Z</dc:date>
    </item>
  </channel>
</rss>

