| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: outfix, line width problem: solved!
I tried Austin's program -outfixt-, it worked! Thank you so much Austin.
(Why don't you get this -outfixt- published at STATA so more people can
download it?)
Weiwei
----- Original Message -----
From: "Austin Nichols" <[email protected]>
To: <[email protected]>
Sent: Tuesday, February 07, 2006 1:25 PM
Subject: Re: st: outfix, line width problem
OK, it seems that outfix2 is also constrained by line length, since it
uses the log file again, but the following revision is not (specify
cap option to suppress screen output, specify format list with format
option). Try -sysuse auto- and -outfixt make turn using r if for==1,
cols(5 30) f(%24s %4.2f)- and -type r- for a demo.
program def outfixt
version 8.2
syntax varlist(min=1) [if] [in] using/ /*
*/, Cols(numlist asc int >0) [ Format(string) replace cap ]
local nvars : word count `varlist'
local ncols : word count `cols'
if `"`format'"'!="" {
local nfmts : word count `format'
}
else local nfmts=`nvars'
if `nvars' != `ncols' | `nvars' != `nfmts' {
di as err "match number of variables, columns, formats"
exit 198
}
tempvar out touse
mark `touse' `if' `in'
file open `out' using "`using'", write `replace'
forv i = 1/`=_N' {
if `touse'[`i'] {
file write `out' _n
`cap' di
forv j = 1/`nvars' {
local cj : word `j' of `cols'
local vj : word `j' of `varlist'
local fj : word `j' of `format'
cap di `fj' `vj'[`i']
if ("`fj'"=="." | _rc) local fj : format `vj'
file write `out' _col(`cj') "`: di `fj' `vj'[`i']'"
`cap' di as txt _col(`cj') `fj' `vj'[`i'] _c
}
}
}
file close `out'
end
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/