<?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 without any delimiter in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397087#M25536</link>
    <description>&lt;P&gt;I tried testing your solution, but the output was not as expected, I get missing values in between the observations. ie., one record is read from raw data file, 12 records after that are missed and shown as missing values , and 13th observation is appearing in the output. please help.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Sep 2017 11:54:12 GMT</pubDate>
    <dc:creator>Thanu</dc:creator>
    <dc:date>2017-09-19T11:54:12Z</dc:date>
    <item>
      <title>Reading a text file without any delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397076#M25532</link>
      <description>&lt;P&gt;How can we import a text file with series of numbers and no delimiters. I need a new observation at every 12th numeric digit. Is this possible? Assume the variable name as 'numbers" with numeric datatype.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;example of contents in text file:&lt;BR /&gt;numbers123456789012345678901234567890123456789012345678&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the sas to read this file like this:&lt;/P&gt;&lt;P&gt;numbers&lt;BR /&gt;123456789012&lt;BR /&gt;345678901234&lt;BR /&gt;567890123456&lt;BR /&gt;789012345678&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TIA,&lt;/P&gt;&lt;P&gt;Thanu&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 11:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397076#M25532</guid>
      <dc:creator>Thanu</dc:creator>
      <dc:date>2017-09-19T11:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file without any delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397077#M25533</link>
      <description>&lt;P&gt;Try the File-&amp;gt;Import Data task, Fixed Width format. &amp;nbsp;You can place the delimiting column positions exactly where you need. &amp;nbsp;It's a gem of a tool.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 11:35:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397077#M25533</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-09-19T11:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file without any delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397081#M25534</link>
      <description>&lt;P&gt;If you literally have no line delimiters or field delimiters then just read it using formatted input.&lt;/P&gt;
&lt;P&gt;Does the file literally have the letters 'numbers' at the beginning? &amp;nbsp;If so that you can conditionally skip those characters on the first pass of the data step.&lt;/P&gt;
&lt;P&gt;Lets setup a dummy file that looks like your example.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename test temp;
data _null_;
  file test recfm=n;
  put 'numbers123456789012345678901234567890123456789012345678';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then we can read that file like this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  infile test recfm=n ;
  if _n_=1 then input +7 @;
  input numbers 12. @@ ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;And we get this resulting data.&lt;/P&gt;
&lt;PRE&gt;Obs       numbers

 1     123456789012
 2     345678901234
 3     567890123456
 4     789012345678
&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Sep 2017 14:20:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397081#M25534</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-19T14:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file without any delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397082#M25535</link>
      <description>&lt;P&gt;This is a part of an automation project we are handling. So I will not be able to file-&amp;gt; import.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can we write a data step? or directly use Proc import.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 11:41:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397082#M25535</guid>
      <dc:creator>Thanu</dc:creator>
      <dc:date>2017-09-19T11:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file without any delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397087#M25536</link>
      <description>&lt;P&gt;I tried testing your solution, but the output was not as expected, I get missing values in between the observations. ie., one record is read from raw data file, 12 records after that are missed and shown as missing values , and 13th observation is appearing in the output. please help.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 11:54:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397087#M25536</guid>
      <dc:creator>Thanu</dc:creator>
      <dc:date>2017-09-19T11:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file without any delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397088#M25537</link>
      <description>I tried testing your solution, but the output was not as expected, I get missing values in between the observations. ie., one record is read from raw data file, 12 records after that are missed and shown as missing values , and 13th observation is appearing in the output. please help.</description>
      <pubDate>Tue, 19 Sep 2017 11:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397088#M25537</guid>
      <dc:creator>Thanu</dc:creator>
      <dc:date>2017-09-19T11:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file without any delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397092#M25538</link>
      <description>&lt;PRE&gt;
Very interesting question.



data have;
input x $1. @@ ;
cards;
numbers123456789012345678901234567890123456789012345678
;
run;
data have;
 set have;
 retain found group 0;
 if anydigit(x) then found=1;
 if found then do;
   n+1;
   if mod(n,12)=1 then group+1;
 end;
run;
data want;
length want $ 20;
 do until(last.group);
  set have;
  by group;
   want=cats(want,x);
 end;
 keep want;
 run;


&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Sep 2017 12:33:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397092#M25538</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-09-19T12:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file without any delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397112#M25539</link>
      <description>&lt;P&gt;Post sample data (make sure to use the Insert Code icon looks like {i}).&lt;/P&gt;
&lt;P&gt;You can also ask SAS to show you the contents.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile 'myfile.txt' obs=4 ;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Sep 2017 13:39:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397112#M25539</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-19T13:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file without any delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397122#M25541</link>
      <description>&lt;P&gt;The File-&amp;gt;Import Data task&amp;nbsp;will generate DATA step code, which you can then copy/adapt. &amp;nbsp;On the last page of the wizard, check "Generalize for use outside of SAS Enterprise Guide" (can't remember exact wording) which will make the code easer to use elsewhere.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you don't know ahead of time how many 12-digit numbers to expect, you might be better off with a solution like that offered by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 13:58:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397122#M25541</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-09-19T13:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file without any delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397137#M25543</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/113111"&gt;@Thanu&lt;/a&gt; wrote:&lt;BR /&gt;I tried testing your solution, but the output was not as expected, I get missing values in between the observations. ie., one record is read from raw data file, 12 records after that are missed and shown as missing values , and 13th observation is appearing in the output. please help.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post the code you used and an example of the data you used with this behavior.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The behavior you describe could mean that your line lengths are different than you expect or you have stuff in you data you haven't explained.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 14:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397137#M25543</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-19T14:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file without any delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397154#M25550</link>
      <description>&lt;P&gt;You need a record layout. If you know you're only reading the first 12 characters you can use the trailing&amp;nbsp;@@ to keep the record in line and keep reading the values. I'll assume you can remove the 'numbers' from the text yourself.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can replace the word CARDS in the INFILE statement with the myFile reference after you point it to your file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;file myfile 'path to my text file';&lt;BR /&gt;data want;
input myvar $12. @@;&lt;BR /&gt;infile cards;
cards;
123456789012345678901234567890123456789012345678
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Sep 2017 15:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-a-text-file-without-any-delimiter/m-p/397154#M25550</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-19T15:09:03Z</dc:date>
    </item>
  </channel>
</rss>

