Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Placing results in a new stata sheet

 From Abhimanyu Arora To statalist@hsphsun2.harvard.edu Subject Re: st: Placing results in a new stata sheet Date Mon, 31 May 2010 23:21:30 +0200

```There could be more efficient ways, but one way  (I assume you
generate the variable result within the loop) is to use a combination
of -outsheet-(-outfile-) and -insheet-(-infile-). Another way could be
to -preserve-, -keep- result, -save- and -restore-

On Mon, May 31, 2010 at 10:50 PM, George Chioran
<george_chioran@yahoo.com> wrote:
> Dear statalisters,
>
> I want to store the
> results that I obtain from several while loops. First I have the time variable “t”:
> 1, 2, 3, … and are in total 16. Then I have the accounts “a”: 210, 245, 256, … and
> are in total 700. In time period 1 I get a different result for all 700
> account. In time period 2 the same happens and so on. I would like to somehow
> save the results that I get from each account under each period.
> My code goes like
> this:
>
> local t = 1
> local a = 1
> While `t’ <= 16 {
>                        While `a’ <=
> 700 {
>                                                    …..
> In this loop I get the results for a = 1 which is r1, for a = 2 which is
> r2 and so on. Could I somehow save the results r1, r2,… in a new stata sheet?
>                                                        local
> a = `a’+1
>                                                         }
>                          local t = `t’ +1
>                          }
>
> I would like the
> results to be placed in a table like this:
> ta                            result
> 1              210                         r1
> 1              245                         r2
> 1              256                         r3
> …             …                             …
> 2              210                         r1
> 2              245                         r2
> 2              256                         r3
> …             …                             …
>
> So when the loop with
> variable t is at 1, the table should put in the first column only 1, in the
> second column the current account and in the third column the result of the current account.
>
>
> Thank you a lot in advance,
> George
>
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index