Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • rowsum in STATA

    Dear All,

    I am a user of STATA/SE 13.1 and have problem with suming matrix by row.
    Example:
    I have a matrix:

    1 2 3
    A = 2 0 -1
    3 -2 0
    and want to create matrix being a sum of rows of matrix A:

    6
    B = 1
    1

    I was using in STATA command matrix B=rowsum(A). The result was: "unknown function rowsum()". r(133).
    Why does it not wark?

    One more question: is it possible to operate in STATA SE on matrix [50000 x 1]?

    Thank you in advance for answer.

    Łukasz

  • #2
    Please note that the correct spelling is Stata, not STATA. http://www.statalist.org/forums/help#spelling

    There is no Stata function rowsum(). There are some add-ons to do such things, but it's better to use Mata, e.g.

    Code:
    . matrix A = (1, 2, 3\2, 0, -1\3, -2, 0) 
    
    . mat li A
    
    A[3,3]
        c1  c2  c3
    r1   1   2   3
    r2   2   0  -1
    r3   3  -2   0
    
    . mata : rowsum(st_matrix("A"))
           1
        +-----+
      1 |  6  |
      2 |  1  |
      3 |  1  |
        +-----+
    Code:
    
    


    So, the question is Why you thought it would work.

    See

    Code:
    help limits
    for limits on matrix size. A matrix with 50,000 rows would need to be held in Mata.

    Comment


    • #3
      Thank you for your hepl.

      Comment

      Working...
      X