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

Putting it together


program define mycmd5
    version 5.0
    local varlist "opt"
    local if "opt"
    local in "opt"
    local options "Detail"
    parse "`*'"

    tempvar touse
    mark `touse' `if' `in'
    markout `touse' `varlist'

    parse "`varlist'", parse(" ")

    while "`1'" != "" {
        mycmdsub `1' `touse' `detail' 
        macro shift
    }
end

program define mycmdsub
    version 5.0
    local name `1'
    local touse `2'
    local detail `3'
    summarize `name' if `touse', `detail'
end

program define mycmd6
    version 6.0




    syntax [varlist] [if] [in] [, Detail]



    marksample touse

    tokenize "`varlist'"

    while "`1'" != "" {
        mycmdsub `1' `touse' `detail' 
        macro shift
    }
end

program define mycmdsub
    version 6.0


    args name touse detail
    summarize `name' if `touse', `detail'
end
The Stata Blog: Not Elsewhere Classified Find us on Facebook Follow us on Twitter LinkedIn Google+ Watch us on YouTube