Tuesday, February 21, 2006

st: sum of rows in matrix

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/


Tag:


Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?