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]

From |
Nick Cox <n.j.cox@durham.ac.uk> |

To |
"'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: RE: how to store the statistics calculated in a loop as a table? |

Date |
Wed, 7 Dec 2011 18:23:55 +0000 |

You can certainly use -forvalues- for a numeric range. That wasn't the point I was making. Nick n.j.cox@durham.ac.uk -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of qing ye Sent: 07 December 2011 18:09 To: statalist@hsphsun2.harvard.edu Subject: Re: st: RE: how to store the statistics calculated in a loop as a table? Thanks for the quick reply. I will check the help file for collapse and tabstat the group takes the value of 1-6, and the varible FF_group_rank_0 takes values of 1-6 stating six groups, so I want to loop for each group, I guess I need to use forvalues rather than foreach? Thanks Qing On 8 December 2011 02:00, Nick Cox <n.j.cox@durham.ac.uk> wrote: > I'd look at -collapse- and/or -tabstat-. > > In any case, your loop > > foreach group of varlist FF_group_rank_0 { > > } > > will do nothing as `group' is never referred to inside the loop. That probably doesn't matter, but it shows some confusion about what -foreach- does. > > Nick > n.j.cox@durham.ac.uk > > qing ye > > Do any of you know how to report the results calculated after the loop > as tables?? > > forvalues i=1990 (1)2010 { > foreach group of varlist FF_group_rank_0 { > forvalues n=1(1)6{ > > > quietly sum EI_t if > trade_date_yearformat==`i' &FF_group_rank_0==`n' > local s_EI=r(sum) > quietly sum BE_t_1 if > trade_date_yearformat==`i' &FF_group_rank_0==`n' > local s_BE=r(sum) > local mean_EI_BE=`s_EI'/`s_BE' > > > } > } > } > > I wanted to have the mean_EI_BE I calculated in the loops reported as a table > > something like the following: > > year group1 group2 group3 group4 group5 group6 > > 1990 x x x > 1991 x x x > 1992 x x x > 1993 x x x > .... > > > > How do I do this? Do I need to use matrix commends to save the > mean_EI_BE I calculated each time or do I need to generate some > variables before the loop and store the mean_EI_BE in those variables? > * * 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/

**References**:**st: how to store the statistics calculated in a loop as a table?***From:*qing ye <yeqing1013@gmail.com>

**st: RE: how to store the statistics calculated in a loop as a table?***From:*Nick Cox <n.j.cox@durham.ac.uk>

**Re: st: RE: how to store the statistics calculated in a loop as a table?***From:*qing ye <yeqing1013@gmail.com>

- Prev by Date:
**st: RE: Non-linear multilevel modeling** - Next by Date:
**Re: st: RE: how to store the statistics calculated in a loop as a table?** - Previous by thread:
**Re: st: RE: how to store the statistics calculated in a loop as a table?** - Next by thread:
**Re: st: RE: how to store the statistics calculated in a loop as a table?** - Index(es):