Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: outfix, line width problem

From   Austin Nichols <>
Subject   Re: st: outfix, line width problem
Date   Tue, 7 Feb 2006 16:25:09 -0500

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'

*   For searches and help try:

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