Announcement

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

  • How to return a value to a stata program?

    Hi Statalisters,

    I want to call another program (var_num) in a Stata program (quantile_reg). But I don't know how to receive the returned value from var_num. Attached are the codes. Appreciate for your help!!


    capture program drop quantile_reg
    program quantile_reg,eclass
    version 12
    syntax varlist(min=2) [if] [in]
    tokenize `varlist'
    marksample touse

    var_num varlist

    mata: mydata(r(N)-1)

    getmata (myvar*)=X,replace
    qreg `1' myvar*,quantile(0.25)
    ereturn list


    end



    capture program drop var_num
    program var_num,rclass
    version 12
    syntax varlist(min=2) [if] [in]
    tokenize `varlist'
    marksample touse

    quietly{
    count if `varlist'!=.
    return scalar N = r(N)
    }
    end

    capture mata mata drop mydata()
    version 12
    mata:
    void mydata(real scalar num)
    {
    st_view(X=.,.,(2..(num)))
    st_view(tau=.,1,num+1)
    }
    end
Working...
X