Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: single spaces in outfile


From   "Nick Winter" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: single spaces in outfile
Date   Wed, 14 Aug 2002 15:12:42 -0400

> -----Original Message-----
> From: Jiang, Tao [mailto:[email protected]] 
> Sent: Wednesday, August 14, 2002 2:08 PM
> To: '[email protected]'
> Subject: st: RE: single spaces in outfile
> 
> 
> I have this kind of problem also.  I am wondering why stata's 
> outfile cannot
> do something like:
> 
> outfile _col(1) v1 _col(10) v2 _col(20) v3 
> 
> or something similar to SAS's "put" command to generate better output?
> 

With the file command, you can roll your own version of this fairly
easily:

   version 6
   file open myfile using <filename>, text write replace
   local N=_N
   forval i=1/`N' {
      local line : di _col(1) varname1[`i'] _col(25) varname2[`i'] ...
      file write myfile `"`line'"' _n
   }
   file close myfile
   version 7

This could be wrapped up in a program pretty easily, I think.  One
important note: the "version 6" directive at the top is key--otherwise
the macro created by the "local line : ..." command will have smcl
directives such as "{col 25}" rather than actual spaces.

Cheers,
Nick Winter
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index