>> Home >> Resources & support >> Users Group meetings >> 5th UK meeting

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.

Stata

Shop

Support

Company


The Stata Blog: Not Elsewhere Classified Find us on Facebook Follow us on Twitter LinkedIn Google+ YouTube
© Copyright 1996–2016 StataCorp LP   •   Terms of use   •   Privacy   •   Contact us