chewfile -- chew and digest ASCII file down to size.


chewfile [using filename] [, options]


chewfile provides a fast and easy way to chew your ASCII file. It will (1) cut down a file down to size, (2) export it as a text file, or (3) force it to read in as strings. It is a supplement to insheet or infile for importing ASCII files.

Use insheet or infile if you want to read it as a number. If it's too big, then read them after cutting it down to size using begin(#), end(#), and save( ).


+------+ ----+ Main +-------------------------------------------------------------

replace Replace the existing file.

clear Read it into memory as strings.

save( ) Must be specified when clear is not specified.

parse(" ") Parsing character. The default is tab. Choose comma like this, parse(",").

begin(#) The starting line to read, inclusive. The default is begin(1).

end(#) The ending line to read, inclusive. The default is end(.).

raw Raw file appears in the first column in addition to the usual stuff. Use this if you want to see unaltered file.


* example data clear set obs 100 gen var1=uniform() gen var2=uniform() gen var3=uniform() outsheet using rawfile.txt, replace noname comma

* import them as strings clear chewfile using rawfile.txt, clear parse(",")

* read through without storing in memory clear chewfile using rawfile.txt, save(chewed_file.txt) replace

* read through only a part of file without storing in memory clear chewfile using rawfile.txt, begin(5) end(.) save(chewed_file.txt) replace


Bare minimum programming. Should work.

First published on Statalist

I have been told the responsible thing to do is to write the help file and put it up on ssc.

You may prefer chunk by David C. Elliott.


Roy Wada

Also see

Online: insheet or infile