<?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: How can I import a txt file without delimiter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899195#M355417</link>
    <description>&lt;P&gt;Read this log file with a DATA step and use the proper line termination string:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data log;
infile "log.txt" termstr=LF truncover;,
input line $256.;
run&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;LF is for text files originating from a UNIX environment. For Windows, use CRLF.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Oct 2023 05:51:42 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-10-19T05:51:42Z</dc:date>
    <item>
      <title>How can I import a txt file without delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899077#M355377</link>
      <description>&lt;P&gt;Dear reader, I am asking for help...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to import a TXT file with just text, but also ; : TAB etc..&lt;/P&gt;&lt;P&gt;I want to get the full file imported- just one variable, the file has 1861 rows but it only imports 20 of them&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This is the code for importing:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;PROC IMPORT DATAFILE="C:\Output\log.txt"&lt;BR /&gt;OUT=LOGFILE&lt;BR /&gt;DBMS=TAB REPLACE;&lt;BR /&gt;GETNAMES=NO;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My LOG:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;NOTE: WORK.LOGFILE data set was successfully created.&lt;BR /&gt;NOTE: The data set WORK.LOGFILE has 20 observations and 1 variables.&lt;BR /&gt;NOTE: PROCEDURE IMPORT used (Total process time):&lt;BR /&gt;real time 0.08 seconds&lt;BR /&gt;cpu time 0.04 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why are 20 lines imported and what can I best do?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I prefer PROC IMPORT...&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 09:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899077#M355377</guid>
      <dc:creator>JohanK</dc:creator>
      <dc:date>2023-10-18T09:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I import a txt file without delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899078#M355378</link>
      <description>&lt;P&gt;PROC IMPORT is a guessing procedure. It guesses how the fields are separated, and in this case it guessed wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can read the data in a DATA step, where you use the INFILE statement with the DLM= option. The DLM= option allows you to specify more than one different delimiters that the file uses. &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm#n14rjz20kqjrgpn1jpffa0x4i9kl" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm#n14rjz20kqjrgpn1jpffa0x4i9kl&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In fact, PROC IMPORT will create (incorrect) code for you, look in the log. You should be able to modify the code so that the DATA step reads the data properly.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 10:04:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899078#M355378</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-18T10:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: How can I import a txt file without delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899086#M355379</link>
      <description>&lt;P&gt;Why did you bother to attach that log? There is NO code that imports any txt file. Everything I see that calls proc import is for XLSX.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unless asked only include log for pieces of code that you have a question about. Since there is nothing in that log with&lt;/P&gt;
&lt;P&gt;PROC IMPORT DATAFILE="C:\Output\log.txt" it is useless. And the snippet that you show is &lt;STRONG&gt;not&lt;/STRONG&gt; the complete log because if you use Proc Import with a Tab delimited file then there will be generated data step code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Causes for fewer observations than you expect could be the file source uses a different end of line marker.&lt;/P&gt;
&lt;P&gt;Which in a data step you use the INFILE statement to set the TERMSTR= option to see if that is the case. TERMSTR=CRLF for Windows source files, TERMSTR=LF for Unix Linux and derivitives and TERMSTR=CR for some other sources.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 11:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899086#M355379</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-10-18T11:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: How can I import a txt file without delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899096#M355384</link>
      <description>&lt;P&gt;You have EOF(end of file) character at 21th row, therefore sas stop reading file when running into it .&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1697630442411.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88937i6EF71244B61389DF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1697630442411.png" alt="Ksharp_0-1697630442411.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add option IGNOREDOSEOF to ignore EOF character to read this fill all.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename x "C:\temp\a\log.txt" termstr=crlf ignoredoseof;

PROC IMPORT DATAFILE=x
OUT=LOGFILE
DBMS=TAB REPLACE;
GETNAMES=NO;
guessingrows=max;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_1-1697630521202.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88938i36D611BD9B502E6B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_1-1697630521202.png" alt="Ksharp_1-1697630521202.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 12:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899096#M355384</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-10-18T12:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I import a txt file without delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899101#M355385</link>
      <description>&lt;P&gt;But I prefer to use data step ,that is simple and easy,if you only want ONE variable in dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
infile  "C:\temp\a\log.txt" termstr=crlf length=len ignoredoseof;
input x $varying1000. len;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1697630924265.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88939i842F228720E6B935/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1697630924265.png" alt="Ksharp_0-1697630924265.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 12:08:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899101#M355385</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-10-18T12:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: How can I import a txt file without delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899102#M355386</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure that I fully understand your requirement, there is mention of Tab characters in the data and that you only want one variable for the whole file, but Tab is in your proc import code too; maybe I'm missing something.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see that you've said you prefer proc import, but as you are having problems with it, you can see if a data step alternative works for, e.g., as per the below untested code (you can change the log_record length if necessary):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data logfile;
  infile "C:\Output\log.txt" truncover;
  input log_record $char256.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 12:15:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899102#M355386</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2023-10-18T12:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: How can I import a txt file without delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899108#M355388</link>
      <description>&lt;P&gt;You don't need to IMPORT text files since SAS can just READ a text file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only reason to use PROC IMPORT to read a delimited file is if you want it to try to GUESS how to read it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you don't have a delimited file there is nothing that it can GUESS for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So just read the file yourself with a DATA step.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 13:00:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899108#M355388</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-10-18T13:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I import a txt file without delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899187#M355410</link>
      <description>&lt;P&gt;Thank you so much Amir, it works !&amp;nbsp;&lt;/P&gt;&lt;P&gt;Greetings, Johan&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 05:21:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899187#M355410</guid>
      <dc:creator>JohanK</dc:creator>
      <dc:date>2023-10-19T05:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: How can I import a txt file without delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899188#M355411</link>
      <description>&lt;P&gt;sorry, not Amir but Mr. Sharp...&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 05:24:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899188#M355411</guid>
      <dc:creator>JohanK</dc:creator>
      <dc:date>2023-10-19T05:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: How can I import a txt file without delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899189#M355412</link>
      <description>Dear ballardw, I have a solution via another user. Many thanks though</description>
      <pubDate>Thu, 19 Oct 2023 05:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899189#M355412</guid>
      <dc:creator>JohanK</dc:creator>
      <dc:date>2023-10-19T05:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: How can I import a txt file without delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899190#M355413</link>
      <description>Dear Paigemiller, many thanks for your reply. I have a solution via another user.</description>
      <pubDate>Thu, 19 Oct 2023 05:26:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899190#M355413</guid>
      <dc:creator>JohanK</dc:creator>
      <dc:date>2023-10-19T05:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: How can I import a txt file without delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899191#M355414</link>
      <description>I have a solution via another user Tom, thanks for your reply!</description>
      <pubDate>Thu, 19 Oct 2023 05:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899191#M355414</guid>
      <dc:creator>JohanK</dc:creator>
      <dc:date>2023-10-19T05:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: How can I import a txt file without delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899195#M355417</link>
      <description>&lt;P&gt;Read this log file with a DATA step and use the proper line termination string:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data log;
infile "log.txt" termstr=LF truncover;,
input line $256.;
run&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;LF is for text files originating from a UNIX environment. For Windows, use CRLF.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 05:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-import-a-txt-file-without-delimiter/m-p/899195#M355417</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-10-19T05:51:42Z</dc:date>
    </item>
  </channel>
</rss>

