Peter Adamson
>
> I am wanting to output variables to a text file for use by
> another program.
> The format of the stata data file is something like:
>
> var1%9.0g var2%9.0g var3%9.0g etc ...
>
> and the format I want is:
>
> var1%9.0g
> var2%9.0g var3%9.0g etc ...
>
> Is there a way to do this using the outfile command?
> Ideally I want to
> write a Carriage Return character to the file to force a
> new line. Any suggestions welcome!
I am not sure that -outfile- will help here.
An alternative is to knit your own.
program def myout
version 7
syntax varlist using
tokenize `varlist'
local first "`1'"
mac shift
local varlist "`*'"
tempname out
file open `out' `using', w
local N = _N
forval i = 1 / `N' { /* MS bug */
file write `out' %9.0g (`first'[`i']) _n
foreach v of local varlist { /* MS bug */
local outlist "`outlist' %9.0g (`v'[`i'])"
}
file write `out' `outlist' _n
local outlist
}
file close `out'
end
Example:
myout var1 var2 var3 using myout.out
should put the first variable value on one line
and the other values on the next line.
Nick
[email protected]
*
* 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/