Dear all,

I've written the following programming to extract b, t-stat, etc. after estimating a regression.
(1) All returned values are characters, but I would like r(b1), r(t1), and r(p1) to be floats, not characters.

Besides, I have two more minor questions.
(2) How can I add 1x5 matrix to be returned? I want the matrix to be (b, t, p, s, sn).
(3) The displayed order of returns when executing "return list" is actually the opposite of the order of definitions described in my programming code. Would there be a way for it to be displayed in the same order as they are defined?

Programming code:

Code:
cap prog drop btps    
    program btps, rclass
        args e_table nth_var
        matrix btps_tab= `e_table'
        
        local b= btps_tab[1,`nth_var']    
        local t= btps_tab[3,`nth_var']    
        local p= btps_tab[4,`nth_var']

        if      `p'<=0.01    local s "***"
        else if `p'<=0.05    local s "**"
        else if `p'<=0.10    local s "*"
        else                 local s "."

        if      `p'<=0.01    local sn "<0.01"
        else if `p'<=0.05    local sn "<0.05"
        else if `p'<=0.10    local sn "<0.1"
        else                 local sn "."                    
        
        display `b'
        display `t'
        display `p'
        display "`s'"
        display "`sn'"
        
        return local b`nth_var'= `b'
        return local t`nth_var'= `t'
        return local p`nth_var'= `p'
        return local s`nth_var' "`s'"
        return local sn`nth_var' "`sn'"
        
        end
Example code of execution:

Code:
    
    
    sysuse auto, clear
    qui: regress mpg trunk foreign turn
    matrix mytable= r(table)
    matrix list mytable
    btps mytable 1
    return list

Returned macros:
Code:
. return list

macros:
r(sn1) : "<0.05"
r(s1) : "**"
r(p1) : ".0233176597830324"
r(t1) : "-2.31903221327864"
r(b1) : "-.3122701936270571"