Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: RE: sum of rows in stata matrix

 From Kieran McCaul <[email protected]> To "[email protected]" <[email protected]> Subject st: RE: sum of rows in stata matrix Date Mon, 7 Oct 2013 12:18:53 +0800

```...

matrix A = (1,2,9\2,7,5\2,4,18)
matrix list A

* This sums across rows of A
matrix X1 = J(3,1,1)
matrix list X1

matrix B1 = A*X1

matrix list B1

*This sums down columns of A
matrix X2 = J(1,3,1)
matrix list X2

matrix B2 = X2*A

matrix list B2

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Shuaizhang Feng
Sent: Monday, 7 October 2013 10:45 AM
To: [email protected]
Subject: st: sum of rows in stata matrix

Dear all:

Suppose I have a matrix A in stata and I want to calculate sum of rows
for each column. What would the most simple way to do it? thanks.

SZ
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```