<?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 Proc Import a txt file number of characters in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Proc-Import-a-txt-file-number-of-characters/m-p/505482#M1176</link>
    <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;I'm trying to use the proc import to import a txt file but some character variables are staying incompletes in the dataset (e.g. 1 character). The code that I'm using is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT OUT= import.results&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATAFILE= "O:\Results2018"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBMS=TAB REPLACE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GETNAMES=YES;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATAROW=2;&lt;BR /&gt;RUN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suggestions to define the number of characters?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Oct 2018 10:23:59 GMT</pubDate>
    <dc:creator>Liane</dc:creator>
    <dc:date>2018-10-18T10:23:59Z</dc:date>
    <item>
      <title>Proc Import a txt file number of characters</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-Import-a-txt-file-number-of-characters/m-p/505482#M1176</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;I'm trying to use the proc import to import a txt file but some character variables are staying incompletes in the dataset (e.g. 1 character). The code that I'm using is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT OUT= import.results&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATAFILE= "O:\Results2018"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBMS=TAB REPLACE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GETNAMES=YES;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATAROW=2;&lt;BR /&gt;RUN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suggestions to define the number of characters?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 10:23:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-Import-a-txt-file-number-of-characters/m-p/505482#M1176</guid>
      <dc:creator>Liane</dc:creator>
      <dc:date>2018-10-18T10:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import a csv file number of characters</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-Import-a-txt-file-number-of-characters/m-p/505487#M1177</link>
      <description>&lt;P&gt;Use a datastep import, then specify the lengths, formats, informats that you know the data should have.&amp;nbsp; This is the best scenario.&amp;nbsp; You change guessingrows to a large number, but its still going to be guessing the data.&lt;/P&gt;
&lt;PRE&gt;proc import...;
  guessingrows=2000;
...
run;&lt;/PRE&gt;
&lt;P&gt;Note that more rows mean more resources needed.&amp;nbsp; Far better to just do:&lt;/P&gt;
&lt;PRE&gt;data import.results;
  infile "o:\results2018.txt" dlm="0a"x;
  length ...;
  informat ...;
  format ...;
  input ...;
run;&lt;/PRE&gt;
&lt;P&gt;This is what proc import generates (you can take it from your log and modify it rather than typing it all in).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some notes:&lt;/P&gt;
&lt;P&gt;Text data with a tab delimiter is&amp;nbsp;&lt;STRONG&gt;not&lt;/STRONG&gt; a CSV file!!&lt;/P&gt;
&lt;P&gt;You filename does not have a file extension.&amp;nbsp; As a text file it should have something like .txt&lt;/P&gt;
&lt;P&gt;Please avoid coding all in uppercase.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 10:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-Import-a-txt-file-number-of-characters/m-p/505487#M1177</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-18T10:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import a txt file number of characters</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-Import-a-txt-file-number-of-characters/m-p/505517#M1181</link>
      <description>&lt;P&gt;The best approach for importing the data when its in .txt file is using a Data step, because you will have control over the variable attributes. Where as PROC IMPORT works on guessing the data types. By default proc import scans first 20 records and decide the data types for the variables. For example when if you have a variable where first 50 records have length of 8 and later 50 then when importing you might get the values truncated after the first 50 records because SAS will set the length based on the first 20 records.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you wish to use PROC IMPORT then use GUESSINGROWS=MAX or else you can switch to Data Step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FYI:&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p13kvtl8ezj13in17i6m99jypcwi.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&amp;nbsp;" target="_blank"&gt;https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p13kvtl8ezj13in17i6m99jypcwi.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 13:00:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-Import-a-txt-file-number-of-characters/m-p/505517#M1181</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-10-18T13:00:06Z</dc:date>
    </item>
  </channel>
</rss>

