<?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 a text file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630387#M186625</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/44100"&gt;@jacksonan123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;The code was:&lt;BR /&gt;&lt;BR /&gt;data one;&lt;BR /&gt;&lt;BR /&gt;infile '/folders/myfolders/partialauc/testsimjuvpilot3.fit' DLM='09'X dsd&lt;BR /&gt;truncover;&lt;BR /&gt;&lt;BR /&gt;input chk $ @;&lt;BR /&gt;&lt;BR /&gt;if chk='id' then delete;&lt;BR /&gt;&lt;BR /&gt;else input @1 id time cmt;&lt;BR /&gt;&lt;BR /&gt;drop chk;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;The data file has the titles repeated after every 24 subjects as below: &lt;BR /&gt;&lt;BR /&gt;ID TIME CMT Y1 Y2 &lt;BR /&gt;&lt;BR /&gt;1.0000E+00 0.0000E+00 1.0000E+00 0.0000E+00 0.0000E+00 &lt;BR /&gt;&lt;BR /&gt;2.4000E+01 2.4000E+01 2.4000E+01 4.2881E+00 4.9617E+01&lt;BR /&gt;&lt;BR /&gt;ID TIME CMT Y1 Y2 &lt;BR /&gt;&lt;BR /&gt;1.0000E+00 0.0000E+00 1.0000E+00 0.0000E+00 0.0000E+00 &lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is the file you show tab delimited?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 07 Mar 2020 17:04:20 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2020-03-07T17:04:20Z</dc:date>
    <item>
      <title>Reading a text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630347#M186602</link>
      <description>&lt;PRE&gt; id	x1	x2	count
1	1	2	1
1	2	3	1
1	2	4	1
id	x1	x2	count
2	1	2	2
2	2	3	2
id	x1	x2	count
3	1	2	3
3	2	3	3
&lt;/PRE&gt;
&lt;P&gt;The inserted data is a (.fit&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 
data one;
infile 'c:\temp\data.fit'  dsd truncover;
input chk $ @;
if chk='id' then delete;
else input @1 id x1 x2 count;
drop chk;
run;
 
proc print; 
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When I try to read the text file I get the following error.&amp;nbsp; Can someone tell me how to correct the code to read the text file?&lt;/P&gt;
&lt;P&gt;NOTE: The infile '/folders/myfolders/partialauc/andre.txt' is:&lt;BR /&gt;Filename=/folders/myfolders/partialauc/andre.txt,&lt;BR /&gt;Owner Name=root,Group Name=root,&lt;BR /&gt;Access Permission=-rwxrwxrwx,&lt;BR /&gt;Last Modified=07Mar2020:08:33:35,&lt;BR /&gt;File Size (bytes)=111&lt;BR /&gt;&lt;BR /&gt;NOTE: Invalid data for id in line 1 1-14.&lt;BR /&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 &lt;BR /&gt;&lt;BR /&gt;1 CHAR id.x1.x2.count 14&lt;BR /&gt;ZONE 66073073066767&lt;BR /&gt;NUMR 9498198293F5E4&lt;BR /&gt;chk=idx1x2 id=. time=. cmt=. _ERROR_=1 _N_=1&lt;BR /&gt;NOTE: Invalid data for id in line 2 1-7.&lt;BR /&gt;&lt;BR /&gt;2 CHAR 1.1.2.1 7&lt;BR /&gt;ZONE 3030303&lt;BR /&gt;NUMR 1919291&lt;BR /&gt;chk=1121 id=. time=. cmt=. _ERROR_=1 _N_=2&lt;BR /&gt;NOTE: Invalid data for id in line 3 1-7.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 13:36:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630347#M186602</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2020-03-07T13:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630348#M186603</link>
      <description>&lt;P&gt;Your data are TAB delimited add DLM='09'x to your INFILE statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1 CHAR id.x1.x2.count 14
  ZONE 66073073066767
  NUMR 9498198293F5E4&lt;/PRE&gt;</description>
      <pubDate>Sat, 07 Mar 2020 13:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630348#M186603</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2020-03-07T13:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630350#M186604</link>
      <description>It worked and may I ask you why so that next time I will know?&lt;BR /&gt;</description>
      <pubDate>Sat, 07 Mar 2020 13:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630350#M186604</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2020-03-07T13:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630351#M186605</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/44100"&gt;@jacksonan123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;It worked and may I ask you why so that next time I will know?&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need DLM='09'x because your data are tab delimited!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS is showing your data line as CHARacters and HEX ZONE-NUMR.&amp;nbsp; Notice the 3rd shown in CHAR as . has ZONE=0 NUMR=9. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1 CHAR id.x1.x2.count 14
  ZONE 66073073066767
  NUMR 9498198293F5E4&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;SAS doesn't know that '09'x is the delimiter but it does know that '09'x is invalid data for a numeric variable.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 14:01:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630351#M186605</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2020-03-07T14:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630355#M186608</link>
      <description>I appreciate the explanation.  However I tried the same code on my recent&lt;BR /&gt;post and it failed.  The data was also  a text file and to me similar to my&lt;BR /&gt;previous example.&lt;BR /&gt;&lt;BR /&gt;Apparently there is something I still don't grasp about text files with&lt;BR /&gt;labels interspersed with data.&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;NOTE: Invalid data for id in line 1 1-305.&lt;BR /&gt;&lt;BR /&gt;RULE:&lt;BR /&gt;----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+-&lt;BR /&gt;---8----+----9----+----0                      &lt;BR /&gt;&lt;BR /&gt; 1          ID          TIME        CMT         Y1          Y2          CP1&lt;BR /&gt;CP2         DV          MDV&lt;BR /&gt;&lt;BR /&gt;      101  X        COUNT       RHYD        RHYL        RMETD       RMETL&lt;BR /&gt;CDLV        CLLV        CVD    &lt;BR /&gt;&lt;BR /&gt;      201       CVL         CRESI       CWRESI      CRES        CWRES&lt;BR /&gt;DV          PRED        RES        &lt;BR /&gt;&lt;BR /&gt;      301   WRES 305&lt;BR /&gt;&lt;BR /&gt;chk=ID id=. time=. cmt=. _ERROR_=1 _N_=1&lt;BR /&gt;&lt;BR /&gt;NOTE: Invalid data for id in line 2 1-31&lt;BR /&gt;</description>
      <pubDate>Sat, 07 Mar 2020 14:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630355#M186608</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2020-03-07T14:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630379#M186620</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/44100"&gt;@jacksonan123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I appreciate the explanation. However I tried the same code on my recent&lt;BR /&gt;post and it failed. The data was also a text file and to me similar to my&lt;BR /&gt;previous example.&lt;BR /&gt;&lt;BR /&gt;Apparently there is something I still don't grasp about text files with&lt;BR /&gt;labels interspersed with data.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;NOTE: Invalid data for id in line 1 1-305.&lt;BR /&gt;&lt;BR /&gt;RULE:&lt;BR /&gt;----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+-&lt;BR /&gt;---8----+----9----+----0 &lt;BR /&gt;&lt;BR /&gt;1 ID TIME CMT Y1 Y2 CP1&lt;BR /&gt;CP2 DV MDV&lt;BR /&gt;&lt;BR /&gt;101 X COUNT RHYD RHYL RMETD RMETL&lt;BR /&gt;CDLV CLLV CVD &lt;BR /&gt;&lt;BR /&gt;201 CVL CRESI CWRESI CRES CWRES&lt;BR /&gt;DV PRED RES &lt;BR /&gt;&lt;BR /&gt;301 WRES 305&lt;BR /&gt;&lt;BR /&gt;chk=ID id=. time=. cmt=. _ERROR_=1 _N_=1&lt;BR /&gt;&lt;BR /&gt;NOTE: Invalid data for id in line 2 1-31&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need to show all relevant code. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This message implies that you are tell SAS you have delimited data that does not exist in the file.&amp;nbsp; For example if you used DSD option which implied DLM=','&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Invalid data for id in line 1 1-305&lt;/PRE&gt;
&lt;P&gt;&lt;FONT style="background-color: #ffffff;"&gt;The message is saying for the variable being read "ID" in LINE 1 &lt;EM&gt;&lt;STRONG&gt;Columns 1-305&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The key data here is 1-305.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 16:17:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630379#M186620</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2020-03-07T16:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630384#M186622</link>
      <description>The code was:&lt;BR /&gt;&lt;BR /&gt;data one;&lt;BR /&gt;&lt;BR /&gt;infile '/folders/myfolders/partialauc/testsimjuvpilot3.fit'  DLM='09'X dsd&lt;BR /&gt;truncover;&lt;BR /&gt;&lt;BR /&gt;input chk $ @;&lt;BR /&gt;&lt;BR /&gt;if chk='id' then delete;&lt;BR /&gt;&lt;BR /&gt;else input @1 id time cmt;&lt;BR /&gt;&lt;BR /&gt;drop chk;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;The data file has the titles repeated after every 24 subjects as below: &lt;BR /&gt;&lt;BR /&gt;ID   TIME  CMT  Y1   Y2 &lt;BR /&gt;&lt;BR /&gt;1.0000E+00  0.0000E+00  1.0000E+00  0.0000E+00  0.0000E+00 &lt;BR /&gt;&lt;BR /&gt;2.4000E+01  2.4000E+01  2.4000E+01  4.2881E+00  4.9617E+01&lt;BR /&gt;&lt;BR /&gt;ID   TIME  CMT  Y1   Y2 &lt;BR /&gt;&lt;BR /&gt;1.0000E+00  0.0000E+00  1.0000E+00  0.0000E+00  0.0000E+00  &lt;BR /&gt;</description>
      <pubDate>Sat, 07 Mar 2020 16:50:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630384#M186622</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2020-03-07T16:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630387#M186625</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/44100"&gt;@jacksonan123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;The code was:&lt;BR /&gt;&lt;BR /&gt;data one;&lt;BR /&gt;&lt;BR /&gt;infile '/folders/myfolders/partialauc/testsimjuvpilot3.fit' DLM='09'X dsd&lt;BR /&gt;truncover;&lt;BR /&gt;&lt;BR /&gt;input chk $ @;&lt;BR /&gt;&lt;BR /&gt;if chk='id' then delete;&lt;BR /&gt;&lt;BR /&gt;else input @1 id time cmt;&lt;BR /&gt;&lt;BR /&gt;drop chk;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;The data file has the titles repeated after every 24 subjects as below: &lt;BR /&gt;&lt;BR /&gt;ID TIME CMT Y1 Y2 &lt;BR /&gt;&lt;BR /&gt;1.0000E+00 0.0000E+00 1.0000E+00 0.0000E+00 0.0000E+00 &lt;BR /&gt;&lt;BR /&gt;2.4000E+01 2.4000E+01 2.4000E+01 4.2881E+00 4.9617E+01&lt;BR /&gt;&lt;BR /&gt;ID TIME CMT Y1 Y2 &lt;BR /&gt;&lt;BR /&gt;1.0000E+00 0.0000E+00 1.0000E+00 0.0000E+00 0.0000E+00 &lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is the file you show tab delimited?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 17:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630387#M186625</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2020-03-07T17:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630389#M186627</link>
      <description>A prior response used this code anydigit designation and it worked as a&lt;BR /&gt;solution:&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;&lt;BR /&gt;infile "/...../myData.fit";&lt;BR /&gt;&lt;BR /&gt;input @;&lt;BR /&gt;&lt;BR /&gt;if anydigit(first(left(_infile_))) then do;&lt;BR /&gt;&lt;BR /&gt;        input @1 ID TIME CMT Y1 Y2; &lt;BR /&gt;&lt;BR /&gt;        output;&lt;BR /&gt;&lt;BR /&gt;        end;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Sat, 07 Mar 2020 17:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630389#M186627</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2020-03-07T17:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630391#M186629</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/44100"&gt;@jacksonan123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;A prior response used this code anydigit designation and it worked as a&lt;BR /&gt;solution:&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;&lt;BR /&gt;infile "/...../myData.fit";&lt;BR /&gt;&lt;BR /&gt;input @;&lt;BR /&gt;&lt;BR /&gt;if anydigit(first(left(_infile_))) then do;&lt;BR /&gt;&lt;BR /&gt;input @1 ID TIME CMT Y1 Y2; &lt;BR /&gt;&lt;BR /&gt;output;&lt;BR /&gt;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The use of ANYDIGIT has nothing to do with your misuse of INFILE statement options.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 17:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630391#M186629</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2020-03-07T17:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630392#M186630</link>
      <description>I agree since the infile statement has been simplified since my designations&lt;BR /&gt;were not correct for the file type I have.&lt;BR /&gt;</description>
      <pubDate>Sat, 07 Mar 2020 17:19:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file/m-p/630392#M186630</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2020-03-07T17:19:13Z</dc:date>
    </item>
  </channel>
</rss>

