Statalist The Stata Listserver

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

Re: st: Outsheet file to "txt" file

From   Joseph Coveney <>
To   Statalist <>
Subject   Re: st: Outsheet file to "txt" file
Date   Thu, 24 Aug 2006 18:15:40 +0900

Marilyn Ibarra wrote:

I am trying to outsheet data from STATA to a ‚?otxt‚?Ě file.  I do not want
comma‚?Ts or tab‚?Ts between columns.  I would like the data to have spacing
(11 spaces) between each column.


I would like to have:

In column 1, a 4 digit number and 7 spaces after the number.  In column 2, a
3 digit number and 8 spaces after the number. Etc‚?¶.


Nicolas Couderc, Ulrich Kohler and Roger Newson mentioned approaches.  In
addition to those, you can use -outfile-.

The code below will put the first digit of the first variable in column 1,
the first digit of the second variable in column 12 and the  first digit of
the third variable in column 23, which is what I think that you're after.

The actual code starts after "Begin here".  The first half-dozen lines, or
so, are just to reproduce your dataset.

Joseph Coveney

set more off
input int variable1 int variable2 long variable3
1122       222        65445
1122       222        65445
1122       222        65445
* Begin here
foreach var of varlist _all {
    tostring `var', replace
    format `var' %-8s
outfile using Eleven-wide.prn, wide noquote

*   For searches and help try:

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