Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: sum of rows in matrix


From   "Lucy Morecroft" <[email protected]>
To   <[email protected]>
Subject   st: sum of rows in matrix
Date   Tue, 21 Feb 2006 11:36:59 +0000

Hi Statalist,

Appologies if this is a very basic question, but a lengthy search of
the archives didn't answer my query.

How can I create a vector, where each element is the sum of each row in
a matrix A?

e.g. let,

mat A=(1,2,3,4,5\6,7,8,9,10)

mat list A

A[2,5]
    c1  c2  c3  c4  c5
r1   1   2   3   4   5
r2   6   7   8   9  10

I would like to create B where:

B[2,1]
    c1
r1  15
r2  40

Thanks in advance,

Lucy




                                        

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