Announcement

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

  • Is there a way to create a matrix with different types (number and string) of elements?

    I am trying to create a matrix in Stata with multiple elements. For example, one column with string variables, one column with numbers, like the one below:

    Code:
                 column1      column2  
    row 1        x is             4         
    row 2        y is             5
    row 3        z is             6
    So I tried the following command:
    Code:
    matrix a = ("x is", 4\"y is", 5\"z is", 6)
    But I got the error message
    Code:
    type mismatch
    r(109);
    I checked the help file of -matrix-, it seems that all the elements in a matrix should be number. Does anyone know how to define a matrix with different types of elements?



  • #2
    Stata matrices are numeric, period. Mata allows string matrices. If you want to mix strings and numbers, you can use tables and/or data. tabdisp is often overlooked here.

    Comment


    • #3
      thanks Nick

      Comment

      Working...
      X