<?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: Import csv data as character (how to force) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Import-csv-data-as-character-how-to-force/m-p/415149#M101794</link>
    <description>&lt;P&gt;Yes, using proc import doesn't really allow for this, it is a guessing procedure.&amp;nbsp; Take the code which is generated by proc import - you should see this in the log, and then modify and run that instead.&amp;nbsp; It will look like:&lt;/P&gt;
&lt;PRE&gt;data want;
  infile "yourfile.csv" dlm=",";
  length vara $10;
  informat vara $10;
  format vara $10;
  input vara $;
run;&lt;/PRE&gt;
&lt;P&gt;With this you can set lengths, informats, formats, for each of the variables you read in.&lt;/P&gt;</description>
    <pubDate>Tue, 21 Nov 2017 12:28:27 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-11-21T12:28:27Z</dc:date>
    <item>
      <title>Import csv data as character (how to force)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-csv-data-as-character-how-to-force/m-p/415145#M101793</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have faced with one error when importing csv.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import out= WORK.LABDATA
            datafile = "lab.csv"
            dbms = CSV REPLACE ;
			delimiter='|';
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;One column was interpreted as numeric but it is character. I received the following error:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Invalid data for PK_DATE in line 169 29-35.
NOTE: Invalid data for PK_TIME in line 169 37-45.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is it possible to define the type of the column when reading CSV formatted data?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 12:26:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-csv-data-as-character-how-to-force/m-p/415145#M101793</guid>
      <dc:creator>DmytroYermak</dc:creator>
      <dc:date>2017-11-21T12:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: Import csv data as character (how to force)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-csv-data-as-character-how-to-force/m-p/415149#M101794</link>
      <description>&lt;P&gt;Yes, using proc import doesn't really allow for this, it is a guessing procedure.&amp;nbsp; Take the code which is generated by proc import - you should see this in the log, and then modify and run that instead.&amp;nbsp; It will look like:&lt;/P&gt;
&lt;PRE&gt;data want;
  infile "yourfile.csv" dlm=",";
  length vara $10;
  informat vara $10;
  format vara $10;
  input vara $;
run;&lt;/PRE&gt;
&lt;P&gt;With this you can set lengths, informats, formats, for each of the variables you read in.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 12:28:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-csv-data-as-character-how-to-force/m-p/415149#M101794</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-21T12:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Import csv data as character (how to force)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-csv-data-as-character-how-to-force/m-p/415151#M101795</link>
      <description>&lt;P&gt;Add one more option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;import&lt;/SPAN&gt; out&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; WORK&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;LABDATA
            datafile &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;"lab.csv"&lt;/SPAN&gt;
            dbms &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; CSV &lt;SPAN class="token keyword"&gt;REPLACE&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
			delimiter&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'|'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;guessingrows=32767;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Nov 2017 12:31:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-csv-data-as-character-how-to-force/m-p/415151#M101795</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-21T12:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: Import csv data as character (how to force)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-csv-data-as-character-how-to-force/m-p/415154#M101796</link>
      <description>&lt;P&gt;I have tried both methods but the second one resoled the issue a little bit faster. Thank you!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just one note: I have to remember further in my program that all the variables are character.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 12:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-csv-data-as-character-how-to-force/m-p/415154#M101796</guid>
      <dc:creator>DmytroYermak</dc:creator>
      <dc:date>2017-11-21T12:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: Import csv data as character (how to force)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-csv-data-as-character-how-to-force/m-p/415160#M101797</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/58513"&gt;@DmytroYermak&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have tried both methods but the second one resoled the issue a little bit faster. Thank you!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just one note: I have to remember further in my program that all the variables are character.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And if you follow the right path and write your own data step, you can read as character into a temporary variable, and deal with the invalid entries by setting the target variable to missing.&lt;/P&gt;
&lt;P&gt;Take control. Also see Maxims 22 &amp;amp; 31.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 13:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-csv-data-as-character-how-to-force/m-p/415160#M101797</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-21T13:05:00Z</dc:date>
    </item>
  </channel>
</rss>

