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

From |
Kit Baum <baum@bc.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Re: How can I loop a FOR command across columns of a matrix |

Date |
Fri, 5 Jun 2009 06:56:34 -0400 |

<> Nathan said I have a 2 x N matrix, such as the following... 2 3 5 10 6 1 2 8 13 6 I would like to write a loop, such as foreach or forvalues, that will take the first and second element of each column, and use them for some operation, and then move on to subsequent columns.

mat f = (2,3,4,10,6\1,2,8,13,6) mat a = f[1,1..5]' mat b = f[2,1..5]' // ssc install matodd qui matewm a b c mat r = c' mat list r

Kit Baum | Boston College Economics & DIW Berlin | http://ideas.repec.org/e/pba1.html

An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html On Jun 5, 2009, at 02:33 , statalist-digest wrote:

I have a 2 x N matrix, such as the following... 2 3 5 10 6 1 2 8 13 6 I would like to write a loop, such as foreach or forvalues, that will take the first and second element of each column, and use them for some operation, and then move on to subsequent columns.

* * 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/

- Prev by Date:
**st: dirtools updated on SSC** - Next by Date:
**RE: st: Reshape like problem** - Previous by thread:
**st: dirtools updated on SSC** - Next by thread:
**st: Random number generation** - Index(es):

© Copyright 1996–2014 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |