>I have a file that is currently in csv format (or I could easily
>convert it to tab-delimited). It is fairly large: roughly 80,000
>observations and 2,200 variables.
You can chew files using -file- command. I have another version
that could do it by columns, but that would be slow. The program
assumes variable names at the top.
* creating data
clear
set mem 333m
set obs 100
gen id=_n
forval n=1/2000 {
gen var`n'=uniform()
}
outsheet using test1.txt, replace
keep in 5/10
save test1, replace
prog drop _all
*! chewfile version 0.9 Aug2008 by [email protected]
program define chewfile
version 8.0
syntax using/, first(integer) last(integer) output(string)
tempname fh outout
local linenum = 0
file open `fh' using `"`using'"', read
file open `outout' using `"`output'"', write replace
file read `fh' line
while r(eof)==0 {
local linenum = `linenum' + 1
if `linenum'==1 | `linenum'>=`first' & `linenum'<=`last' {
*display %4.0f `linenum' _asis `"`macval(line)'"'
file write `outout' `"`macval(line)'"' _n
}
file read `fh' line
}
file close `fh'
file close `outout'
end
clear
chewfile using test1.txt, first(6) last(11) output(mystuff.txt)
* checking
insheet using mystuff.txt, clear
append using test1
_________________________________________________________________
Get thousands of games on your PC, your mobile phone, and the web with Windows�.
http://clk.atdmt.com/MRT/go/108588800/direct/01/
*
* 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/