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

Saved results, more details

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

program define mycmdsub
    version 6.0
    args name touse detail
    summarize `name' if `touse', `detail'
After mycmd6 mpg weight length:
        . return list
               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.