Announcement

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

  • Arguments for .ado-file/program

    Hi All,

    I have some code that I have frequently pasted into various .do files. Instead; I would like to create a standalone program and add it to stata in the same way I would from ssc. However, I am having problems defining the arguments for the program.

    I would like to have the following code:

    corrstat JP_large JP_med, null(0.9)

    Run the program (correlates JP_large, JP_med and gives me p-value under null that rho=0.9)

    I believe the error lies in the very first part and so have included the beginning snippet:

    "“
    program define corrstat
    syntax varlist, [null(real 0)] [location(string "$matrix")] [name(string "DEFAULT")]
    preserve
    * keep only the concerned variables
    keep `varlist'
    * number of variables
    desc
    local varnum=`r(k)'
    …” "
    Last edited by Ilia Karmanov; 16 Sep 2014, 09:55.

  • #2
    You don't spell out what Stata did and said. Do please read FAQ Advice #12.

    Options taking string arguments don't have defaults, at least not so far as syntax is concerned. You can set up defaults easily by something like

    Code:
     
    if "`location'" == "" local location "$matrix"
    but your syntax statement is illegal.

    Comment

    Working...
    X