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

Re: st: appending two variables


From   Joseph Coveney <jcoveney@bigplanet.com>
To   Statalist <statalist@hsphsun2.harvard.edu>
Subject   Re: st: appending two variables
Date   Fri, 19 Nov 2004 18:30:09 +0900

David K Evans wrote:

So I want to run 10,000 iterations of a process, but I'm not using Stata
SE, so I can't put more than 800 iterations in a given column of a matrix.

The problem is that if I want to do summary statistics, on the different
estimates, I would normally just use svmat to turn the matrix into a
variable and then 'summarize' that.

Is there any way to take two variables, say X and Y, and put them end to
end (ultimately creating a dataset that has 10,000 observations, where
each observation is an outcome).

----------------------------------------------------------------------------

I'm not quite sure that I follow you, but you can use a -tempfile- to save
the first batch, create the second batch, and use -append- to put them
together end-to-end, -save , replace- back to the temporary file, and
continue until your iterations are done.  (Illustrated below.)

You'll need to have the same variable name, however.  If you want to append
two unrelated variables side-to-side, then you can use -merge- in a way that
I hadn't realized it could be used in, myself, until just last week when
Scott Merryman pointed it out:
www.hsph.harvard.edu/cgi-bin/lwgate/STATALIST/archives/statalist.0411/date/a
rticle-413.html

Joseph Coveney

clear
set more off
tempfile tmp
save `tmp', emptyok
forvalues iteration = 1/13 {
    set obs 800
    generate float X = uniform()
    append using `tmp'
    save `tmp', replace
    drop X
}
use `tmp', clear
erase `tmp'
exit







*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index