Announcement

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

  • Row and column labels with mat2txt2 package

    Hello,

    I am trying to export a matrix to a csv file using the mat2txt2 package. I have a 4x4 matrix whose rows represent starting months (number of months in the future) and the columns represent the maturity of an interest rate. I have these stored in the following macros:

    global CycleForecastStart 0 3 6 12
    global CycleForecastHorizon 3 6 9 12

    I have some results saved under the matrix InflResults. I am attempting to export the matrix using the two macros above as follows:

    mat2txt2 InflResults using "Results.csv", rowlabel("$CycleForecastStart") collabel("$CycleForecastHorizon") replace comma

    I have also tried without the quotes, but I get an "option rowlabel() incorrectly specified" error. The help of mat2txt2 though is not very helpful in understanding how this argument should be specified.

    Does anyone know how I can specify the labels correctly?

    Thanks

  • #2
    I don't know the mat2txt2 command (per FAQ, you should have specified its source). But do you really need CSV format? How about tab-delimited with the user-written command mat2txt (by Blasnik and Jann at SSC)? That should work if you are interested in importing with some spreadsheet (or other) application. An example:

    Code:
    matrix A = 1, 2 \ 3, 4
    matrix colnames A = 1 column2
    matrix rownames A = row1 row2
    
    matrix list A
    
    mat2txt, matrix(A) saving(mattest.txt) replace
    You should:

    1. Read the FAQ carefully.

    2. "Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!"

    3. Describe your dataset. Use list to list data when you are doing so. Use input to type in your own dataset fragment that others can experiment with.

    4. Use the advanced editing options to appropriately format quotes, data, code and Stata output. The advanced options can be toggled on/off using the A button in the top right corner of the text editor.

    Comment

    Working...
    X