<?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: read in text file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/read-in-text-file/m-p/773805#M245880</link>
    <description>&lt;P&gt;Thank you Tom! I really appreciate your solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best!&lt;/P&gt;</description>
    <pubDate>Wed, 13 Oct 2021 01:18:39 GMT</pubDate>
    <dc:creator>runrunbunny</dc:creator>
    <dc:date>2021-10-13T01:18:39Z</dc:date>
    <item>
      <title>read in text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-in-text-file/m-p/773800#M245877</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a text file including several columns are all about customers' comments like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;FilePath&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Comments&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Score&lt;/P&gt;
&lt;P&gt;0937bj903.wav&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I don't like your service at all&amp;nbsp;balabala&amp;nbsp;&amp;nbsp;&amp;nbsp; Negative&lt;/P&gt;
&lt;P&gt;rt707bj690.wav&amp;nbsp;&amp;nbsp;&amp;nbsp; Great service&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Positive&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;8897b66er.wav&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;No idea&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Neutral&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have trouble reading this text&amp;nbsp;file since the length of the column&amp;nbsp;'Comments' are not the same, so I am not able to define which column to start and end, which directly leads in mis-reading the column 'Score' as well. So I have to define the length of each column, but it's not working properly:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; FilePath $&amp;nbsp;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#08726d"&gt;13&amp;nbsp; &lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;Comments $ &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#08726d"&gt;30&amp;nbsp; &lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3" color="#08726d"&gt;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#08726d"&gt;&lt;FONT face="Courier New" size="3"&gt;Score&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;$ &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#08726d"&gt;10&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;infile&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;"data\file.txt"&lt;/FONT&gt; &lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;FilePath $&amp;nbsp; Comments&amp;nbsp;$&amp;nbsp;&amp;nbsp; Score $ ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please give me some suggestions in how to dealing with this kind of text file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;R.B&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 23:46:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-in-text-file/m-p/773800#M245877</guid>
      <dc:creator>runrunbunny</dc:creator>
      <dc:date>2021-10-12T23:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: read in text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-in-text-file/m-p/773804#M245879</link>
      <description>&lt;P&gt;First is make sure that those spaces between the columns are not actually tab characters.&lt;/P&gt;
&lt;P&gt;A simple way to check is to use the LIST statement in a data step.&amp;nbsp; The '09'x hex codes of a TAB character will trigger the list statement to display the hex codes for you to examine. If they are all spaces then LIST will not both listing the hex codes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile 'myfile' obs=5;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If they are tabs then use '09'x as the delimiter.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  length FilePath $ 13   Comments $ 30    Score$ 10;
  infile "data\file.txt" dlm='09'x ;
  input FilePath  Comments Score ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise if SCORE is always only one word then just read everything into COMMENTS and move the last word into SCORE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  length FilePath $ 13   Comments $ 30    Score$ 10;
  infile "data\file.txt"  truncover ;
  input FilePath  Comments $30. ;
  score=scan(comments,-1,' ');
  comments=substrn(comments,1,length(comments)-length(score));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Oct 2021 00:15:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-in-text-file/m-p/773804#M245879</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-13T00:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: read in text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-in-text-file/m-p/773805#M245880</link>
      <description>&lt;P&gt;Thank you Tom! I really appreciate your solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 01:18:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-in-text-file/m-p/773805#M245880</guid>
      <dc:creator>runrunbunny</dc:creator>
      <dc:date>2021-10-13T01:18:39Z</dc:date>
    </item>
  </channel>
</rss>

