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 |
Thomas Speidel <thomas@tmbx.com> |

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

Subject |
Re: st: egen rowmean, loops and if |

Date |
Tue, 05 Apr 2011 14:09:54 -0700 |

I have a wide dataset: +-------------------------------------+ | id occ_~1_1 occ_~2_1 occ_~3_1 | |-------------------------------------| | 1 4 7 . | | 2 1.5 . . | | 3 2.3 3.3 . | | 4 3.3 2.3 3.5 | | 5 1.5 . . | |-------------------------------------| | 6 1.5 . . | | 7 2.3 . . | | 8 1.5 . . | | 9 1.5 2.3 3.3 | | 10 1.5 2.3 3.3 | +-------------------------------------+ where occ_~1_1 = occ_met1_1 occ_~2_1 = occ_met2_1 occ_~3_1 = occ_met3_1 Of course, the data is much wider (and taller), with occ_metj_i j = 1 to <=3 i = 1 to <=8

+-----------------------------------------------------+ | id occ_~1_1 occ_~2_1 occ_~3_1 mean1_1 mean2_1 | |-----------------------------------------------------| | 1 4 7 . 5.50 . | | 2 1.5 . . . 1.50 | | 3 2.3 3.3 . 2.80 . | | 4 3.3 2.3 3.5 3.03 . | | 5 1.5 . . . 1.50 | |-----------------------------------------------------| | 6 1.5 . . . 1.50 | | 7 2.3 . . 2.30 . | | 8 1.5 . . . 1.50 | | 9 1.5 2.3 3.3 2.80 1.50 | | 10 1.5 2.3 3.3 2.80 1.50 | +-----------------------------------------------------+

foreach j of num 1/3 { foreach i of num 1/8 {

} } Thanks. * * 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/

**Follow-Ups**:**Re: st: egen rowmean, loops and if***From:*Nick Cox <njcoxstata@gmail.com>

**References**:**st: egen rowmean, loops and if***From:*Thomas Speidel <thomas@tmbx.com>

- Prev by Date:
**st: egen rowmean, loops and if** - Next by Date:
**st: -esttab- problem** - Previous by thread:
**st: egen rowmean, loops and if** - Next by thread:
**Re: st: egen rowmean, loops and if** - Index(es):