Announcement

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

  • Save tuples names

    Hellow, I want to save tuples names in a matrix

    tuples l_docente l_matri,display
    matrix p = J(3,1,.)
    local i = 1
    forvalues i=1/3 {
    quietly sfpanel l_grad `tuple`i'', model(bc95)
    local res = "`tuple`i''"
    matrix p[`i',1]=`res'
    local i++
    }

    please, help me

  • #2
    tuples is from SSC (FAQ Advice # 12).

    local res = "`tuple`i''"
    matrix p[`i',1]=`res'
    Stata matrices cannot have string elements. But you could do this in Mata.

    Code:
    sysuse auto, clear
    tuples mpg price weight turn, disp
    mata: p13= (( "`tuple13'")',strofreal(J(1,1,.),"%2.1f"))
    mata: p13
    Res.:

    Code:
    . tuples mpg price weight turn, disp
    tuple1: turn
    tuple2: weight
    tuple3: price
    tuple4: mpg
    tuple5: weight turn
    tuple6: price turn
    tuple7: price weight
    tuple8: mpg turn
    tuple9: mpg weight
    tuple10: mpg price
    tuple11: price weight turn
    tuple12: mpg weight turn
    tuple13: mpg price turn
    tuple14: mpg price weight
    tuple15: mpg price weight turn
    
    . 
    . mata: p13= (( "`tuple13'")',strofreal(J(1,1,.),"%2.1f"))
    
    . 
    . mata: p13
                        1                2
        +-----------------------------------+
      1 |  mpg price turn                .  |
        +-----------------------------------+
    
    .

    Comment


    • #3
      thank you soo much. I didn't remember that Stata matrices cannot have string elements.

      Comment

      Working...
      X