<?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: Formating .txt files to specification in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342296#M272812</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
filename fylfat "d:/txt/txtbig.txt" lrecl=16000 recfm=v;

* create the input fat file;
data sasfat;
        informat state $2. num1-num720 best21.;
        infile fylfat end=dne;
        input state $ num1-num720 ;
        output;
        if _n_=3 then stop;
run;quit;

proc print data=sasfat;
format num1-num720 21.17;
run;quit;

Norte SAS cannot handle 18 significat digits(you need R or Python for 18 sig digit arithmetic)

1.0021709654943634  Original number
1.0021709654943600  SAs number (lost precistion)

Obs  STATE                   NUM1                   NUM2  ...                  NUM720

 1    AK      1.00217096549436000    1.00414185896059000  ...     2.26668456775932000
 2    AL      1.00203845526359000    1.00408994140026000  ...     2.70441496537969000
 3    AR      1.00187083703867000    1.00367877037134000  ...     2.27810994554249000


Middle Observation(1 ) of sasfat - Total Obs 3

 -- CHARACTER --
STATE                            C    2       AK                  STATE


 -- NUMERIC --
NUM1                             N    8       1.0021709655        NUM1
NUM2                             N    8       1.004141859         NUM2
NUM3                             N    8       1.0059412003        NUM3
NUM4                             N    8       1.0075022638        NUM4
NUM5                             N    8       1.0089031672        NUM5
NUM6                             N    8       1.0103131154        NUM6
...
NUM717                           N    8       2.2575557326        NUM717
NUM718                           N    8       2.2610511943        NUM718
NUM719                           N    8       2.2640534503        NUM719
NUM720                           N    8       2.2666845678        NUM720


If you want to maintain precision you van use python (R does not have a native 64 bit integers)

Drop the decimal until last calc then add it with a format;

* there are extended precision packages in R and python;
* did not add the code to place the decimal you need a format;

%utl_submit_py64('
import numpy as np;
big1=np.int64(10021709654943634);
print(big1);
big1=np.int64(80000000000000008/4 );
print(big1);
');

1.0021709654943634
2.0000000000000002

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 18 Mar 2017 23:27:18 GMT</pubDate>
    <dc:creator>rogerjdeangelis</dc:creator>
    <dc:date>2017-03-18T23:27:18Z</dc:date>
    <item>
      <title>Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342127#M272800</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;I have data that looks like this (the bold font is for effect and ease of reading):
&lt;BR /&gt;AK 1.0021709654943634 1.004141858960591 1.0059412003301735 1.0075022638405597 1.0089031671832394 1.010313115448636 1.011885064154461 1.0136625876807632 1.0156754189935162 1.0177783819813138 1.0197049657091506 1.0214077118629967 1.023113899728484 1.024961812812696 1.0270842976676144AL 1.0020384552635933 1.004089941400261 1.0060428591630741 1.0078924898011783 1.0097674543713253 1.0116008228367985 1.0134279114567353 1.0152999141462276 1.0173619485116154 1.0194078638786026 1.0213379906824893 1.023262316198122 1.0251279177514947 1.0270029541971306 1.0289116457759255 1.030797300045038 1.0326897516732034AR 1.0018708370386706 1.003678770371349 1.0053816820500132 1.0069865858906413 1.0086739002665075 1.0103784241907938 1.0121787224179806 1.0140531846329055 1.015902586876032 1.0177222600477227 1.019508177957654 1.0212688572482178 1.0229772574375544 1.0247276546883293 1.026411549887851 1.0281958089836294 1.0301388665899276 




And I am trying to make it look like this, instead.
AK 1.0021709654943634 1.004141858960591 1.0059412003301735 1.0075022638405597 1.0089031671832394 1.010313115448636 1.011885064154461 1.0136625876807632 1.0156754189935162 1.0177783819813138 1.0197049657091506 1.0214077118629967 1.023113899728484 1.024961812812696 1.0270842976676144
AL 1.0020384552635933 1.004089941400261 1.0060428591630741 1.0078924898011783 1.0097674543713253 1.0116008228367985 1.0134279114567353 1.0152999141462276 1.0173619485116154 1.0194078638786026 1.0213379906824893 1.023262316198122 1.0251279177514947 1.0270029541971306 1.0289116457759255 1.030797300045038 1.0326897516732034
AR 1.0018708370386706 1.003678770371349 1.0053816820500132 1.0069865858906413 1.0086739002665075 1.0103784241907938 1.0121787224179806 1.0140531846329055 1.015902586876032 1.0177222600477227 1.019508177957654 1.0212688572482178 1.0229772574375544 1.0247276546883293 1.026411549887851 1.0281958089836294 1.0301388665899276 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Can someone please propose code to accomplish what I am looking for above? I am at&amp;nbsp;a loss.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 19:23:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342127#M272800</guid>
      <dc:creator>maroulator</dc:creator>
      <dc:date>2017-03-17T19:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342142#M272801</link>
      <description>&lt;P&gt;Is that first posted&amp;nbsp;data in a SAS data set? If so lets see the results of proc contents.&lt;/P&gt;
&lt;P&gt;Or is that the result of sending the data from SAS to text? If so show the code or describe the process used.. That result appears as if you are looking at a file formatted for one operating system with a different operating sytem viewer.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 19:58:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342142#M272801</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-17T19:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342143#M272802</link>
      <description>Hi:&lt;BR /&gt;  Is your data in a SAS dataset? In an ASCII text file? In a CSV file? It looks like your data might not have LINE FEEDS in it. &lt;BR /&gt;&lt;BR /&gt;  What code have you tried? Where does this data come from? What do you need to do with it (other than make it look like there's only 1 state per row)? &lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Fri, 17 Mar 2017 20:00:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342143#M272802</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-03-17T20:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342147#M272803</link>
      <description>&lt;P&gt;This might help clarify matters; what I posted earlier was a representation of a larger dataset. I attach this larger dataset below; I am trying to&amp;nbsp;convert the attached .txt file into a&amp;nbsp;SAS dataset that has the format I describe, in order to for it better feed into some other downstream processes that I am dealing with.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 20:16:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342147#M272803</guid>
      <dc:creator>maroulator</dc:creator>
      <dc:date>2017-03-17T20:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342148#M272804</link>
      <description>&lt;P&gt;Cynthia,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for reaching out. See the response that I have to your colleague above; I will add that this dataset was generated by an internal system and I am trying to get it into the format I described in my original post to make some downstream processes run more smoothly. Hope this clarifies matters.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 20:18:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342148#M272804</guid>
      <dc:creator>maroulator</dc:creator>
      <dc:date>2017-03-17T20:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342169#M272805</link>
      <description>&lt;P&gt;Proc contents on the data set used and &lt;STRONG&gt;please&lt;/STRONG&gt; describe how you generated the output text file that looks like one row, Code would be best.&lt;/P&gt;
&lt;P&gt;Options might include:&lt;/P&gt;
&lt;P&gt;Data step with PUT statement (s)&lt;/P&gt;
&lt;P&gt;Proc Export (though I would expect some column header)&lt;/P&gt;
&lt;P&gt;Proc Print, again would expect column headers&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or is that one row the result of the internal process and you have not done anything in SAS with it?&lt;/P&gt;
&lt;P&gt;To reformat a file with SAS it has to be a data set at one point for most purposes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you attempted to read the file into SAS and didn't get the result you need, show the code with the log.&lt;/P&gt;
&lt;P&gt;Also, what operating system did the process that generated that file use? Which operating system are you running SAS on?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 22:03:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342169#M272805</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-17T22:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342180#M272806</link>
      <description>&lt;P&gt;I am not sure that the file is just one row. When I open the HPA.TXT file with NoteTab Light, it looks like this: &lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7819i74895A6397532E77/image-size/original?v=1.0&amp;amp;px=-1" alt="look_data_notetab.png" title="look_data_notetab.png" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;Note how AK, AL, and AR all start at the beginning of a new line. So I wonder if this is an issue of no CR or LF at the end of a row of data or whether this was generated on some system and then FTP'd incorrectly so the CR/LF did not get translated correctly. Or something.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, I -could- read the file. There are a LOT of numbers. I just did a simple&lt;/P&gt;
&lt;P&gt;to count the number of decimals in the INFILE buffer and each "row" for each "state" had 720 decimals, which is how I came up with the ending number for the INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But there is still strangeness in the file. I used this to start:&lt;CODE class=" language-sas"&gt; &lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data explore;
  infile 'c:\temp\HPA.txt' length=lg lrecl=32767 missover termstr=LF;
  ** read state and hold the data line;
  input state $ @;
     numdec = count(_infile_,'.');
     putlog _n_= lg= state= numdec=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;just to get the number of decimal places (in order to read the variables after STATE) and this is what I got in the log:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7820i159DAE4B329AF246/image-size/original?v=1.0&amp;amp;px=-1" alt="show_log.png" title="show_log.png" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;So it might be that there is something weird at the end of the file, but given that STATE has the correct value for _n_ 1, 2, and 3, I think that it should be possible to read the file and just skip over the lg=1 or any lg=0 data lines that might be coming from odd control characters in the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I tried&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7821i95497B17F7A5AE9C/image-size/original?v=1.0&amp;amp;px=-1" alt="read_big_lines.png" title="read_big_lines.png" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;and the proc print looks OK, but I did not even try to show all 720 numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And, of course, this is only a sample of 3, but I would be tempted to go back to the folks who designed this process and have them check what is being put at the bottom of the file. And, possibly sweet talk them into using normal CR/LF. Bottom line, is that I don't think this ASCII text file is ever going to be "readable" in Notepad in any meaningful way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cynthia&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 22:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342180#M272806</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-03-17T22:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342190#M272807</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SAS Forum: Splitting a long single record into 50 state lines

inspired by
https://goo.gl/yxQTBh
https://communities.sas.com/t5/General-SAS-Programming/Formating-txt-files-to-specification/m-p/342127

There are several places in SAS where you need a 'null' like
dataset or flatfile.
This is epecially true when you want to create
a dataset with 'proc sql' but you do not need or have a dataset.
or you are using 'input @@'.

I expect this type of problem to be a one liner in Perl or Python?

I copied your long record to flatfile

HAVE ( Your one line file and my 'null' flatfile )
=================================================

 'null' file d:\txt\empty.txt

      d:/txt/fylfat.txt  (one reord 3 bytes 'EOF')

   INPUTS

      Filename=d:\txt\empty.txt,
      File List=('d:\txt\fylfat.txt' 'd:\txt\empty.txt'),
      RECFM=V,LRECL=4096

      Filename=d:\txt\fylfat.txt,
      File List=('d:\txt\fylfat.txt' 'd:\txt\empty.txt'),
      RECFM=V,LRECL=4096

NOTE: 1 record was read from the infile FYLFAT.
      The minimum record length was 926.
      The maximum record length was 926.


AK 1.0021709654943634 1.004141858960591 ... 1.005941200330173592AL ... 1.0059412003301735
==                                                              =

WANT
====

Up to 40 obs from sasnrm total obs=3

Obs                       LYN

 1  AK 1.0021709654943634 1.004141858960591 ... 1.0059412003301735
 2  AL 1.0020384552635933 1.004089941400261 ... 1.0060428591630741
 3  AR 1.0018708370386706 1.003678770371349 ... 1.0053816820500132


Middle Observation(1 ) of sasnrm - Total Obs 3

 -- CHARACTER --
LYN             C    512     AK 1.00217096549

WORKING CODE
============

   filename fylfat ("d:/txt/fylfat.txt","d:/txt/empty.txt" ) lrecl=4096;
   input num @@;
   lyn=catx(' ',lyn,num);

FULL SOLUTION
=============

* create 'null' like dataset;
data _null_;
 file "d:/txt/empty.txt";
 put 'EOF';
run;quit;


filename fylfat ("d:/txt/fylfat.txt","d:/txt/empty.txt" ) lrecl=4096;

* create the input fat file;
data sasnrm;
length lyn $512;
retain lyn;
informat num $21.;
infile fylfat;
input num @@;
if lengthn(compress(num,'.','d'))&amp;gt;0 and _n_ &amp;gt; 1 then do;
   output;
   lyn='';
   num=compress(num,'.','d');
   lyn=catx(' ',lyn,num);
   num=compress(num,'.','kd');
   lyn=catx(' ',lyn,num);
end;
else do;
   lyn=catx(' ',lyn,num);
end;
if num=:'EOF' then output;
drop num;
run;quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Mar 2017 23:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342190#M272807</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-03-17T23:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342192#M272808</link>
      <description>&lt;P&gt;Just opening the sample text file you've attached with Notepad++ reveals that your lines with numbers end with a UNIX style LF&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7822iB20E2FC2D02F348B/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could it be that your downstream process expects a Windows style CRLF as end of record indicator? If this process is in SAS then use TERMSTR as part of your Infile statement.&amp;nbsp;&lt;A href="http://support.sas.com/kb/14/178.html" target="_blank"&gt;http://support.sas.com/kb/14/178.html&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Comment:&lt;/P&gt;
&lt;P&gt;I'm referring to sample data HPA.txt. The larger sample file others refer to hasn't been available anymore in this thread.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Mar 2017 01:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342192#M272808</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-03-19T01:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342201#M272809</link>
      <description>&lt;P&gt;The larger file seems to have several issues&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
I adjusted my code to handle the full file. It seems to work.

filename fylfat ("d:/txt/txtbig.txt","d:/txt/empty.txt" ) lrecl=32756 recfm=v;
length lyn $32756;


I can simplify the code if I can be sure the CRLF are between all states.

Here is a proc contents showing 3 lines with more numbers.

R, Python and Perl allow entire files to to loaded into one variable(myfile) and
strsplit(myfile) would create a vector of 'words' for the entire file which you
could resphape into lines of x numbers and output or convert to numeric arrays of rows.&lt;BR /&gt;WPS does not limit the size of the SAS dataset coming out of R (or Python?)

Observations           3

Alphabetic List of Variables and Attributes

#    Variable    Type      Len

1    LYN         Char    13493


Note the 0D0A(crlf) in the 168th 80 byte  chunk
Another one for AL at 340th 80 byte chunk.&lt;BR /&gt;&lt;BR /&gt;FYI this is output from by utlrulr macro, which I have posted several times.&lt;BR /&gt;A better way ti view hes id FSLIST, but you need full base SAS for that (not EG)

 --- Record Number ---  169   ---  Record Length ---- 80

56006 2.2640534503322765 2.2666845677593237..AL 1.0020384552635933 1.00408994140
1...5....10...15...20...25...30...35...40...45...50...55...60...65...70...75...8
33333232333333333333333323233333333333333330044232333333333333333323233333333333
5600602E264053450332276502E2666845677593237DA1C01E002038455263593301E00408994140&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Mar 2017 00:41:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342201#M272809</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-03-18T00:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342208#M272810</link>
      <description>&lt;P&gt;If the lines are really that regular then it might&amp;nbsp;be simple to fix.&lt;/P&gt;
&lt;P&gt;If the lines actually do have LF at the ends of each record (which I doubt because your original program should have worked) then just read it and&amp;nbsp;re-write it using CR-LF at the ends of the lines.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   infile 'oldfile' termstr=lf ;
   file 'newfile' termstr=crlf ;
   input;
   put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first few numbers make it looks like the numbers are always 18 characters long. &amp;nbsp;Are there always the same numbers after each state? So if there are 18 numbers for each state then perhaps you can just read it like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   infile 'oldfile' recfm=n ;
   file 'newfile' termstr=crlf ;
   input state  ;
   put state $2. @ ;
   do i=1 to 15 ;
     input number ;
     put  +1 number best18. @;
  end;
  put;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise read the thing character by character and when you see a letter then spit out an end of line.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   infile 'oldfile' recfm=f lrecl=1 end=eof;
   file 'newfile' termstr=crlf ;
   input ch $char1.  ;
   retain numch 0;
   numch = mod(numch + anyalpha(ch),3);
   if numch=1 and _n_&amp;gt; 1 then put ;
   if ch not in ('0A'x,'0D'x) then put ch $char1. @;
   if eof then put ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Mar 2017 02:02:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342208#M272810</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-03-18T02:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342259#M272811</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Interesting that the OP program did not work with termstr=LF, but my program DID work with termstr=LF. When I tried my simple program, to capture the length of each data line and count the number of decimals:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data explore;
  infile 'c:\temp\HPA.txt' length=lg lrecl=32767 missover termstr=LF;
  ** read state and hold the data line;
  input state $ @;
     numdec = count(_infile_,'.');
     putlog _n_= lg= state= numdec=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;here are the line lengths I got for each data line:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7824i1B31766CBAB24F16/image-size/original?v=1.0&amp;amp;px=-1" alt="read_hpa.png" title="read_hpa.png" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;At least one of my data lines (for state=AR had a length of 13493, which agrees with Roger's length of one of his datalines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used termstr=LF in my code. So I think that is delimiting the records. I tried other values for termstr as shown below and none of these worked as well as termstr=LF:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--tried termstr=CRLF and termstr=CR neither of them did as well as termstr=LF&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7825i2C2CB18659218B80/image-size/original?v=1.0&amp;amp;px=-1" alt="other_termstr.png" title="other_termstr.png" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;also tried termstr='0D0A'x and that did not work either:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7826i298AD21F69764FD1/image-size/original?v=1.0&amp;amp;px=-1" alt="term_0D0A.png" title="term_0D0A.png" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the OP has not come back to answer Tom's question about whether there are always 18 numbers after every STATE value or to comment on the number of decimal points that I found on every data line -- it seems unusual to me that there are exactly 720 periods for every data line -- that seems too regular a pattern.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And my final program&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data explore;
  infile 'c:\temp\HPA.txt' length=lg lrecl=32767 missover termstr=LF;
  ** read state and hold the data line;
  input state $ @;
  numdec = count(_infile_,'.');
  if state gt ' ' and lg gt 0 and numdec gt 0 then do;
     input val1-val720;
     putlog _n_= lg= state= val1= val2= val3= numdec=;
	 output;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;seemed to produce the desired SAS dataset....but required some exploration to come up with the right logic and variable counts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cynthia&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2017 19:03:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342259#M272811</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-03-18T19:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342296#M272812</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
filename fylfat "d:/txt/txtbig.txt" lrecl=16000 recfm=v;

* create the input fat file;
data sasfat;
        informat state $2. num1-num720 best21.;
        infile fylfat end=dne;
        input state $ num1-num720 ;
        output;
        if _n_=3 then stop;
run;quit;

proc print data=sasfat;
format num1-num720 21.17;
run;quit;

Norte SAS cannot handle 18 significat digits(you need R or Python for 18 sig digit arithmetic)

1.0021709654943634  Original number
1.0021709654943600  SAs number (lost precistion)

Obs  STATE                   NUM1                   NUM2  ...                  NUM720

 1    AK      1.00217096549436000    1.00414185896059000  ...     2.26668456775932000
 2    AL      1.00203845526359000    1.00408994140026000  ...     2.70441496537969000
 3    AR      1.00187083703867000    1.00367877037134000  ...     2.27810994554249000


Middle Observation(1 ) of sasfat - Total Obs 3

 -- CHARACTER --
STATE                            C    2       AK                  STATE


 -- NUMERIC --
NUM1                             N    8       1.0021709655        NUM1
NUM2                             N    8       1.004141859         NUM2
NUM3                             N    8       1.0059412003        NUM3
NUM4                             N    8       1.0075022638        NUM4
NUM5                             N    8       1.0089031672        NUM5
NUM6                             N    8       1.0103131154        NUM6
...
NUM717                           N    8       2.2575557326        NUM717
NUM718                           N    8       2.2610511943        NUM718
NUM719                           N    8       2.2640534503        NUM719
NUM720                           N    8       2.2666845678        NUM720


If you want to maintain precision you van use python (R does not have a native 64 bit integers)

Drop the decimal until last calc then add it with a format;

* there are extended precision packages in R and python;
* did not add the code to place the decimal you need a format;

%utl_submit_py64('
import numpy as np;
big1=np.int64(10021709654943634);
print(big1);
big1=np.int64(80000000000000008/4 );
print(big1);
');

1.0021709654943634
2.0000000000000002

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Mar 2017 23:27:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342296#M272812</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-03-18T23:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342302#M272813</link>
      <description>&lt;P&gt;Ah, I see what&amp;nbsp; you mean. &lt;BR /&gt;cynthia&lt;/P&gt;</description>
      <pubDate>Sun, 19 Mar 2017 00:58:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342302#M272813</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-03-19T00:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342598#M272814</link>
      <description>&lt;P&gt;Hi, sorry I was out of pocket for most of the weekend, so I got to this only just now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I generated the output file that looks like one row (a.k.a "Output File") from an internal process; SAS has nothing to do with it, all I can see from this internal process&amp;nbsp;is the Output File. A &lt;STRONG&gt;new file&lt;/STRONG&gt; that I attach below is the log file generated by SAS after I attempted to import&amp;nbsp;the Output File into PC SAS by using the import wizard. I am running PC SAS on Windows 7.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 14:04:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342598#M272814</guid>
      <dc:creator>maroulator</dc:creator>
      <dc:date>2017-03-20T14:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342603#M272815</link>
      <description>&lt;P&gt;Did you generate the file on your PC? &amp;nbsp;If not then how did you transfer the file to your PC?&lt;/P&gt;
&lt;P&gt;Perhaps your file transfer method is what is removing the end of lines. &amp;nbsp;Or inserting extra end of lines after about 13K characters. &amp;nbsp;Perhaps your original file was generated without any characters between lines. &amp;nbsp;Of if you make it on an IBM mainframe then perhaps it used a file format that does not store the end of line characters in the data and your transfer method did not insert them in the right places.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There probably is no advantage to trying to use the guessing tool to import the data, but if you do use it you should check the box that says there is not a line with variable names at the top of the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also it looks like the PROC IMPORT did not see any split between the state name and the first value so it tried to use them both as the name for the first column. &amp;nbsp;This means you probably told it to use the wrong character as the delimiter.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 14:29:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342603#M272815</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-03-20T14:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: Formating .txt files to specification</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342628#M272816</link>
      <description>&lt;P&gt;You text&amp;nbsp;file is easy to read with PC SAS. There is nothing wrong with the end of lines or the format (other than three blank lines at the end of the file). &amp;nbsp; There is no need to use PROC IMPORT or other tools to ask SAS to guess at what is in the file. &amp;nbsp;Just write a data step to read it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you didn't specify what names you wanted for the variables I just made some up. Also your data file has three blank lines at the end so I added code to delete those.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path= C:\Downloads ;

data want;
  infile "&amp;amp;path\HPA.txt" truncover;
  length state $2 value1-value720 8 ;
  input state value1-value720 ;
  if state=' ' then delete ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Mar 2017 15:07:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formating-txt-files-to-specification/m-p/342628#M272816</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-03-20T15:07:50Z</dc:date>
    </item>
  </channel>
</rss>

