1) open the file in a text editor, remove the extra 6 bytes, import
with constant record length, restore the removed 6 bytes manually
2) use binary read/write commands, read byte by byte in a double-loop
(1 by records 1..101, second by characters 1..record_length)
How do you know that it is the first record that is longer, not, say, 25th?
Regards,
Sergiy Radyakin
On Wed, Nov 19, 2008 at 2:59 PM, Even Bergseng <[email protected]> wrote:
> Dear listers!
>
> I have a txt-file without end-of-line delimiter and uneven record length that I want to read into Stata. The lack of end-of-lin delimiters and hence all observations on one line, suggests using the _lrecl option of the -infile2- command. The uneven record length suggests otherwise.
>
> There is only one uneven record (1975 bytes) which occurrs at the beginning of the file. All other records are 1969 bytes. There are 100 records excluding the first.
>
> I have tried to use -file read- and then -file write- to get rid of the first uneven record to be able to use -infile-, but the total line length and thus the macro from -file read- makes Stata state "too few quotes" when I try to write it with -file write-.
>
> My code for the -file- command is as follows:
>
> ****
> tempname OUT1
> file open `OUT1' using "$sima\OUT1.dat", read write text
> file seek `OUT1' 1975
> file read `OUT1' line
> file close `OUT1'
> tempname RESULT
> file open `RESULT' using "$sima\RESULT.dat", read write text
> file write `RESULT' (`"`macval(line)'"')
> file close `RESULT'
> ***
>
> Any hints on how th read the txt-file?
>
> best regards,
> Even Bergseng
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/