<?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 raw files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/232544#M42395</link>
    <description>&lt;P&gt;Your data file is different than your first example. There are a number of header records and some of the records contain tabs instead of spaces.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regardless, I think the following either works or comes extremely close:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA need;&lt;BR /&gt;INFILE "/folders/myfolders/test.txt" truncover;&lt;BR /&gt;informat s_fil $20.;&lt;BR /&gt;input @;&lt;BR /&gt;if strip(_infile_) eq '' then do;&lt;BR /&gt;call missing(s_fil);&lt;BR /&gt;input;&lt;BR /&gt;end;&lt;BR /&gt;else if substr(_infile_,1,3) in ('S.A','ENT','FLL','---','STA') or&lt;BR /&gt;substr(_infile_,24,4) eq 'SERV' then do;&lt;BR /&gt;call missing(s_fil);&lt;BR /&gt;input;&lt;BR /&gt;end;&lt;BR /&gt;else if anyalpha(substr(_infile_,26,5)) then do;&lt;BR /&gt;input s_fil &amp;amp;;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;else if substr(_infile_,1,1) eq '09'x then do;&lt;BR /&gt;_infile_=compress(_infile_,'09'x);&lt;BR /&gt;_infile_=cat(' ',strip(_infile_));&lt;BR /&gt;INPUT agda_num $24-26&lt;BR /&gt;serv_msg_num $29-32&lt;BR /&gt;con $37-44&lt;BR /&gt;ret $46-59&lt;BR /&gt;dt2 $61-68&lt;BR /&gt;txn $70-75&lt;BR /&gt;hr_txn_dt $77-84&lt;BR /&gt;pgto_pc $86-87&lt;BR /&gt;valor $100-110&lt;BR /&gt;age_tax_enrlmt_nbr $116-128&lt;BR /&gt;;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;else do;&lt;BR /&gt;INPUT sta $1-4&lt;BR /&gt;cal $6-8&lt;BR /&gt;sg $12-12&lt;BR /&gt;dt1 $15-22&lt;BR /&gt;agda_num $24-26&lt;BR /&gt;serv_msg_num $29-32&lt;BR /&gt;con $37-44&lt;BR /&gt;ret $46-59&lt;BR /&gt;dt2 $61-68&lt;BR /&gt;txn $70-75&lt;BR /&gt;hr_txn_dt $77-84&lt;BR /&gt;pgto_pc $86-87&lt;BR /&gt;valor $100-110&lt;BR /&gt;age_tax_enrlmt_nbr $116-128&lt;BR /&gt;;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;data want (drop=next:);&lt;BR /&gt;recnum=_n_+1;&lt;BR /&gt;set need end=last;&lt;BR /&gt;if not last and missing(s_fil) then do;&lt;BR /&gt;set need (keep=s_fil rename=(s_fil=next_s_fil)) point=recnum;&lt;BR /&gt;if not missing(next_s_fil) then s_fil=next_s_fil;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;else if last and missing(s_fil) then output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 31 Oct 2015 01:16:44 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2015-10-31T01:16:44Z</dc:date>
    <item>
      <title>Reading raw files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/232480#M42371</link>
      <description>&lt;P&gt;Hi mates,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I&amp;nbsp;need a way to create a three positional input due the following txt file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;F   015   3  20151029 019  0100             00000000000000 20151029 102004 20151029                     47,28     1530215000019
591 PAGAMENTO INCLU
019  0100             00000000000000 20151029 102155 20151029                    212,50     1530215000020
.   .
018  0023             00000000000000 20151029 103258 20151029                    538,85     1530215000021
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first line will start with the F in the column1, 015 in the column 2 and 3 in the column3, all the other values should match for the first row, but in the third row the "019" should be at the same position of "019" in the first line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To understant what i'm saying, the first textbox is how my raw file is in SAS, the second textbox bellow is represented on how the third row should begin:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;F   015   3  20151029 019  0100             00000000000000 20151029 102004 20151029                     47,28     1530215000019
591 PAGAMENTO INCLU
                      019  0100             00000000000000 20151029 102155 20151029                    212,50     1530215000020
.   .
                      018  0023             00000000000000 20151029 103258 20151029                    538,85     1530215000021
&lt;/PRE&gt;
&lt;P&gt;So what i want is to read the first and the second line and print the into the first line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The third row should begin to read or print the value at the same column of the "019" and put missing to the first 4 columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The final output i'm trying to make&amp;nbsp;is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;F| 015| 3| 20151029   |   019 | 0100 | 00000000000000| 20151029 |102004| 20151029|   47,28     |1530215000019| 591| PAYMENT
 |    |  |            |   019 | 0100 | 00000000000000| 20151029 |102155| 20151029|  212,50     |1530215000020| 591| PAYMENT
 |    |  |            |   018 | 0023 | 00000012344534| 20151029 |103258| 20151029|  538,85     |1530215000021|    |
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code is this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA TEST;
/*	INFILE "/home/re43526/quickview/TI47_*.txt"*/
/*        TRUNCOVER FIRSTOBS=11;*/
	INPUT 	 F1		$1-4
			 F2		$4-8
			 F3		$22-25
			 F4		$26-34
			 F5		$43-58
			 F6		$
			 F7		$
			 F8		$
			 F9		$
			 F10    $115-135
			 #2
			 F11	$1-4
			 F12	$4-50;
	CARDS;
F   015   3  20151029 019  0100             00000000000000 20151029 102004 20151029                     47,28     1530215000019
591 PAYMENT
019  0100             00000000000000 20151029 102155 20151029                    212,50     1530215000020
.   .
018  0023             00000000000000 20151029 103258 20151029                    538,85     1530215000021
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But i'm having a lot trouble to make this.&lt;/P&gt;
&lt;P&gt;Can you help me ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 16:51:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/232480#M42371</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-10-30T16:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/232490#M42374</link>
      <description>&lt;P&gt;Does the sequence repeat? &amp;nbsp; Is there only one "F" record in the file or for every 3 records there is a F record followed by an address record followed by a shifted "018" or "019" record ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would like to see some more data. &amp;nbsp;With limited infomation, should be doable.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 17:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/232490#M42374</guid>
      <dc:creator>kannand</dc:creator>
      <dc:date>2015-10-30T17:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/232492#M42375</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;F   003   3  20150515 002  0001     1467190 00000000000000 20150515 123928 20150515            237.925.559,51     0762813002413
172 PAYMENT
002  0001     1467190 00000000000000 20150515 123929 20150515             38.271.480,73     0762813002414
172 PAYMENT
002  0001     1470370 00000000000000 20150515 143314 20150515                254.311,29     0762813002417
F   011   1  20150323 005  0031    31073808 00000581701860 20150323 074917 20150323 03                 411,43     0000000000000
.   .
005  0031    31080804 00000826413048 20150323 085940 20150323 03                 244,42     0000000000000
.   .&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actualy I need make just like an IF condition.&lt;/P&gt;
&lt;P&gt;The point is: &amp;nbsp;"&lt;/P&gt;
&lt;PRE&gt;F   003   3  20150515 002&lt;/PRE&gt;
&lt;P&gt;This part the "002" is in the position 21 or 22, but the third line also should be at the same position, but it isn't,&lt;/P&gt;
&lt;P&gt;begins&amp;nbsp;at the first position.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 18:06:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/232492#M42375</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-10-30T18:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/232497#M42377</link>
      <description>&lt;P&gt;Not sure if this is exactly what you want, but should be close enough that you can adjust as needed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA TEST;&lt;BR /&gt;/* INFILE "/home/re43526/quickview/TI47_*.txt"*/&lt;BR /&gt;/* TRUNCOVER FIRSTOBS=11;*/&lt;BR /&gt;infile cards truncover;&lt;BR /&gt;input @;&lt;BR /&gt;if mod(_n_,3) eq 1 then&lt;BR /&gt;INPUT F1 $1-4&lt;BR /&gt;F2 $5-7&lt;BR /&gt;F3 $8-11&lt;BR /&gt;F4 $14-21&lt;BR /&gt;F5 $22-25&lt;BR /&gt;F6 $26-31&lt;BR /&gt;F7 $43-58&lt;BR /&gt;F8 $60-67&lt;BR /&gt;F9 $68-74&lt;BR /&gt;F10 $76-83&lt;BR /&gt;F11 $100-109&lt;BR /&gt;F12 $115-135&lt;BR /&gt;#2&lt;BR /&gt;F13 $1-4&lt;BR /&gt;F14 $4-50;&lt;BR /&gt;else if mod(_n_,3) eq 2 then&lt;BR /&gt;INPUT F5 $1-4&lt;BR /&gt;F6 $6-11&lt;BR /&gt;F7 $22-37&lt;BR /&gt;F8 $38-45&lt;BR /&gt;F9 $47-52&lt;BR /&gt;F10 $54-61&lt;BR /&gt;F11 $72-87&lt;BR /&gt;F12 $90-105&lt;BR /&gt;#2&lt;BR /&gt;F13 $1-4&lt;BR /&gt;F14 $4-50;&lt;BR /&gt;else&lt;BR /&gt;INPUT F5 $1-4&lt;BR /&gt;F6 $6-11&lt;BR /&gt;F7 $22-37&lt;BR /&gt;F8 $38-45&lt;BR /&gt;F9 $47-52&lt;BR /&gt;F10 $54-61&lt;BR /&gt;F11 $72-87&lt;BR /&gt;F12 $90-105&lt;BR /&gt;;&lt;BR /&gt;CARDS;&lt;BR /&gt;F 015 3 20151029 019 0100 00000000000000 20151029 102004 20151029 47,28 1530215000019&lt;BR /&gt;591 PAYMENT&lt;BR /&gt;019 0100 00000000000000 20151029 102155 20151029 212,50 1530215000020&lt;BR /&gt;. .&lt;BR /&gt;018 0023 00000000000000 20151029 103258 20151029 538,85 1530215000021&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 18:45:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/232497#M42377</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-10-30T18:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/232512#M42382</link>
      <description>&lt;P&gt;Art, thanks this kind i solved, but when use infile "with my txt file", there are some lines that i don't need to read.&lt;/P&gt;
&lt;P&gt;Check out the attachment to see what i'm talking about.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 20:31:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/232512#M42382</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-10-30T20:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Reading raw files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/232544#M42395</link>
      <description>&lt;P&gt;Your data file is different than your first example. There are a number of header records and some of the records contain tabs instead of spaces.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regardless, I think the following either works or comes extremely close:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA need;&lt;BR /&gt;INFILE "/folders/myfolders/test.txt" truncover;&lt;BR /&gt;informat s_fil $20.;&lt;BR /&gt;input @;&lt;BR /&gt;if strip(_infile_) eq '' then do;&lt;BR /&gt;call missing(s_fil);&lt;BR /&gt;input;&lt;BR /&gt;end;&lt;BR /&gt;else if substr(_infile_,1,3) in ('S.A','ENT','FLL','---','STA') or&lt;BR /&gt;substr(_infile_,24,4) eq 'SERV' then do;&lt;BR /&gt;call missing(s_fil);&lt;BR /&gt;input;&lt;BR /&gt;end;&lt;BR /&gt;else if anyalpha(substr(_infile_,26,5)) then do;&lt;BR /&gt;input s_fil &amp;amp;;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;else if substr(_infile_,1,1) eq '09'x then do;&lt;BR /&gt;_infile_=compress(_infile_,'09'x);&lt;BR /&gt;_infile_=cat(' ',strip(_infile_));&lt;BR /&gt;INPUT agda_num $24-26&lt;BR /&gt;serv_msg_num $29-32&lt;BR /&gt;con $37-44&lt;BR /&gt;ret $46-59&lt;BR /&gt;dt2 $61-68&lt;BR /&gt;txn $70-75&lt;BR /&gt;hr_txn_dt $77-84&lt;BR /&gt;pgto_pc $86-87&lt;BR /&gt;valor $100-110&lt;BR /&gt;age_tax_enrlmt_nbr $116-128&lt;BR /&gt;;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;else do;&lt;BR /&gt;INPUT sta $1-4&lt;BR /&gt;cal $6-8&lt;BR /&gt;sg $12-12&lt;BR /&gt;dt1 $15-22&lt;BR /&gt;agda_num $24-26&lt;BR /&gt;serv_msg_num $29-32&lt;BR /&gt;con $37-44&lt;BR /&gt;ret $46-59&lt;BR /&gt;dt2 $61-68&lt;BR /&gt;txn $70-75&lt;BR /&gt;hr_txn_dt $77-84&lt;BR /&gt;pgto_pc $86-87&lt;BR /&gt;valor $100-110&lt;BR /&gt;age_tax_enrlmt_nbr $116-128&lt;BR /&gt;;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;data want (drop=next:);&lt;BR /&gt;recnum=_n_+1;&lt;BR /&gt;set need end=last;&lt;BR /&gt;if not last and missing(s_fil) then do;&lt;BR /&gt;set need (keep=s_fil rename=(s_fil=next_s_fil)) point=recnum;&lt;BR /&gt;if not missing(next_s_fil) then s_fil=next_s_fil;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;else if last and missing(s_fil) then output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Oct 2015 01:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-raw-files/m-p/232544#M42395</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-10-31T01:16:44Z</dc:date>
    </item>
  </channel>
</rss>

