Announcement

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

  • How to print a matrix with horizontal lines?

    I need to add horizontal lines in a matrix (so that I can distinguish observations in my study).

    In particular, consider the following matrix:
    Code:
    version 18
    mata:
    temp = colshape(1 .. 60, 10)
    temp
    end
    Then, the result is
    Code:
    : temp
            1    2    3    4    5    6    7    8    9   10
        +---------------------------------------------------+
      1 |   1    2    3    4    5    6    7    8    9   10  |
      2 |  11   12   13   14   15   16   17   18   19   20  |
      3 |  21   22   23   24   25   26   27   28   29   30  |
      4 |  31   32   33   34   35   36   37   38   39   40  |
      5 |  41   42   43   44   45   46   47   48   49   50  |
      6 |  51   52   53   54   55   56   57   58   59   60  |
        +---------------------------------------------------+
    Here, I want to add horizontal lines under even number rows.
    That is, the result I want to make is
    Code:
            1    2    3    4    5    6    7    8    9   10
        +---------------------------------------------------+
      1 |   1    2    3    4    5    6    7    8    9   10  |
      2 |  11   12   13   14   15   16   17   18   19   20  |
         ---------------------------------------------------
      3 |  21   22   23   24   25   26   27   28   29   30  |
      4 |  31   32   33   34   35   36   37   38   39   40  |
         ---------------------------------------------------
      5 |  41   42   43   44   45   46   47   48   49   50  |
      6 |  51   52   53   54   55   56   57   58   59   60  |
        +---------------------------------------------------+
    But, I cannot find the solution.
    How can I add the horizontal lines?

  • #2
    I don't know a way to do this in Mata without writing your own function. If you're listing data, use list in Statawith the option sep(2).

    Comment

    Working...
    X