Statalist The Stata Listserver


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

st: Re: Adding an observation to a dataset


From   Friedrich Huebler <[email protected]>
To   [email protected]
Subject   st: Re: Adding an observation to a dataset
Date   Wed, 7 Jun 2006 08:28:05 -0700 (PDT)

Allan,

You created a table of various statistics in a Stata dataset with
-collapse- and other commands. To convert this data to a nicely
formatted Word table you can use -listtex-.

. ssc d listtex

Export your variables as a tab-delimited text file, copy the contents
of the file to Word, select the text, and then use the Word function
Convert - Table - Text to Table.

Friedrich Huebler

--- "Allan Reese (Cefas)" <[email protected]> wrote:
> To construct a table of various derived statistics, one approach is
> to collapse the data.  I then wanted an extra line for totals. 
> Searching help found a function within Mata but otherwise suggested
> creating a temporary file with one case then appending it to the
> original.  However, a direct approach worked in a DO file and seems
> worth documenting on this list:
> 
>    local nn=_N+1
>    set obs `nn'
> 
> The other part of the task, for completeness, includes forming
> totals of numbers, weights, percentages: 
>  
>    egen pcbyn = pc(nitem)
>    egen totn = sum(nitem)
>    egen totnpc = sum(pcbyn)   /* should be 100 */
> * Copy column totals down to pseudo-observation (now 'last'). 
>    quietly {
>       local nn=_N+1
>       set obs `nn'
>       replace Species = "Total   ...  "   in l
>       replace nitem=totn[1]               in l
>       replace pcbyn=totnpc[1]             in l
>    }
>    list species nitem pcbyn
> 
> Searching the archive for advice on copying output to Word found a
> suggestion to use Ctrl/Shift/C which would copy a table with tabs. 
> Didn't work for me.  Still limited to copying text and formatting
> in Word as Courier/9pt to get fixed spacing.
> 
> Allan

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
*
*   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