<?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: Reading data from text files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-text-files/m-p/91111#M257367</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've attached the file by editing my question. I couldn't attach the file in my reply (that was the issue preventing me from attaching it). &lt;/P&gt;&lt;P&gt;Please check. &lt;/P&gt;&lt;P&gt;I'm not sure about the origin of the data file (whether Unix env. or not). I'm assuming it was created in windows. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Sep 2013 06:25:51 GMT</pubDate>
    <dc:creator>sridhar78</dc:creator>
    <dc:date>2013-09-24T06:25:51Z</dc:date>
    <item>
      <title>Reading data from text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-text-files/m-p/91107#M257363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a text file (test4.txt) which has the following columns&lt;/P&gt;&lt;P&gt;Gender, Age, S1, S2, S3 and S4. Here S1-S4 are numeric variables.&lt;/P&gt;&lt;P&gt;The program or code below worked fine on SAS desktop learning edition. But when I ran it on the EG 4.3 it is not reading correctly.&lt;/P&gt;&lt;P&gt;The data on the last columns it not being read. Sometimes zero is read as zero and sometimes it is read as"blank/null"&lt;/P&gt;&lt;P&gt;How do I ensure that SAS reads the data correctly? Please advice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code I wrote is below:-&lt;/P&gt;&lt;P&gt;data lib2.test4;&lt;/P&gt;&lt;P&gt;infile "/home/sridhar78/sridharv/test4.txt";&lt;/P&gt;&lt;P&gt;input gender$ age s1 s2 s3 s4;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Data file "text4.txt" &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Male 27 1 8 0 0&lt;/P&gt;&lt;P&gt;Female 29 3 14 5 10&lt;/P&gt;&lt;P&gt;Female 34 2 10 3 3&lt;/P&gt;&lt;P&gt;Male 35 2 112 4 8&lt;/P&gt;&lt;P&gt;Female 36 4 16 3 7&lt;/P&gt;&lt;P&gt;Male 21 1 5 0 0&lt;/P&gt;&lt;P&gt;Male 25 2 9 2 1&lt;/P&gt;&lt;P&gt;Female 21 1 4 2 6&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output I get is as below:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;27&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Female&lt;/TD&gt;&lt;TD&gt;29&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;14&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Female&lt;/TD&gt;&lt;TD&gt;34&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;35&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;112&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Female&lt;/TD&gt;&lt;TD&gt;36&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;16&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Female&lt;/TD&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 05:25:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-text-files/m-p/91107#M257363</guid>
      <dc:creator>sridhar78</dc:creator>
      <dc:date>2013-09-24T05:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-text-files/m-p/91108#M257364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you please attach your test file "test4.txt" so that we can have a look into it. I assume it has something to do with delimiters and/or end-of-line indicators.&lt;/P&gt;&lt;P&gt;Are you running your code under Windows or Unix?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could try:&lt;/P&gt;&lt;P&gt;infile "/home/sridhar78/sridharv/test4.txt" &lt;STRONG&gt;TRUNCOVER&lt;/STRONG&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 05:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-text-files/m-p/91108#M257364</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-09-24T05:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-text-files/m-p/91109#M257365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Patrick, &lt;/P&gt;&lt;P&gt;I'm unable to attach the txt file. Hence I've pasted the data above. &lt;/P&gt;&lt;P&gt;Test4 is a regular text file and the delimiter is space. &lt;/P&gt;&lt;P&gt;There are no inconsistencies such as missing data, wrong delimiter, etc. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To answer your question, I'm running the code in Windows. &lt;/P&gt;&lt;P&gt;I tried using TRUNCOVER, but still seeing the same output. Please advice. &lt;/P&gt;&lt;P&gt;thanks for your prompt response. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 05:52:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-text-files/m-p/91109#M257365</guid>
      <dc:creator>sridhar78</dc:creator>
      <dc:date>2013-09-24T05:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-text-files/m-p/91110#M257366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The forums here allow you to attach a file. What's holding you back?&lt;/P&gt;&lt;P&gt;The reason I'm after the original data source is that I suspect the issue is somewhere with whitespace characters (so a TAB instead of a BLANK or LF instead of CRLF as end-of-line indicators). This is something which can only be detected by looking into the original data source.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I kind-of suspect end-of-line indicators as interestingly the very last line of your data gets read as you want it. Does this file - by any chance - originate from a Unix environment?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 06:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-text-files/m-p/91110#M257366</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-09-24T06:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-text-files/m-p/91111#M257367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've attached the file by editing my question. I couldn't attach the file in my reply (that was the issue preventing me from attaching it). &lt;/P&gt;&lt;P&gt;Please check. &lt;/P&gt;&lt;P&gt;I'm not sure about the origin of the data file (whether Unix env. or not). I'm assuming it was created in windows. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 06:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-text-files/m-p/91111#M257367</guid>
      <dc:creator>sridhar78</dc:creator>
      <dc:date>2013-09-24T06:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-text-files/m-p/91112#M257368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to include the infile statement option TERMSTR=CRLF;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you switched the program from desktop SAS to EG you changed the OS to UNIX, I suspect.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 11:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-text-files/m-p/91112#M257368</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-09-24T11:21:26Z</dc:date>
    </item>
  </channel>
</rss>

