Home  /  Resources & support  /  Users Group meetings  /  1999 UK Stata Users Group meeting  /  Saved results, more details

Saved results, more details


mycmd6.ado:
program define mycmd6, rclass
    version 6.0
    syntax [varlist] [if] [in] [, Detail]

    marksample touse

    tokenize `varlist'

    return scalar nvar = 0
    while "`1'" != "" {
        mycmdsub `1' `touse' `detail' 
        macro shift
        return scalar nvar = return(nvar) + 1
    }
end

program define mycmdsub
    version 6.0
    args name touse detail
    summarize `name' if `touse', `detail'
end
After mycmd6 mpg weight length:
        . return list
        
        scalars:
               r(nvar)        =  3
Note use of return(nvar) rather than r(nvar). return() is used to consume results you have set in the program. r() is used to consume results of other commands.