UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

What's New in Stata 9: Prefix Commands

* Several commands have been eliminated and made into a prefix for other commands
* One example of this is the svy commands, which we will get to in a few minutes.
* Prefixes can now have options

* list of prefix commands
/*

    by           run command on subsets of data
    statsby      same as by, but collect statistics from each run
    rolling      run command on moving subsets, and collect statistics

    bootstrap    run command on bootstrap samples
    jackknife    run command on jackknife subsets of data
    permute      run command on random permutations
    simulate     run command on manufactured data

    svy          run command and adjust results for survey sampling
    stepwise     run command with stepwise variable inclusion/exclusion
    xi           run command after expanding factor variables & interactions

    capture      run command and capture its return code
    noisily      run command and show the output
    quietly      run command and suppress the output
    version      run command under specified version
*/
use http://www.ats.ucla.edu/stat/stata/notes/hsb2, clear
* same as Stata 8
xi: regress write i.ses

* naming the prefix
xi , prefix(dum): regress write i.ses

* making all of the dummies
xi , noomit prefix(ndum):  regress write i.ses, nocons

* bootstrap and jackknife are now prefixes
regress write read female
bootstrap, reps(100) : regress write read female
jackknife: regress write read female

* the same commands with some options included so that the outputs are close together
* and can be easily compared
regress write read female, nohead
bootstrap, reps(100) nohead nodots: regress write read female
jackknife, nohead nodots: regress write read female

mean read write math
bootstrap, reps(100) nohead nodots:  mean read write math
jackknife, nohead nodots:  mean read write math

* this example shows getting a median (we need to do it this way because of our data set)
bootstrap r(p50), reps(500) nodots: summarize write, detail

* permute is now a prefix

permute female sum=r(sum), right nodrop nodots reps(1000): summarize read if ~female
permute female r(p50), reps(1000) right nodrop nodots: summarize read if ~female, detail

* rolling is a new prefix

* Los Angeles seasonal rainfall 1878 to present

use http://www.ats.ucla.edu/stat/stata/seminars/stata9/larain, clear
* desc
list in 1/30
twoway scatter laseason year, xlabel(1900(50)2000)
summarize
tsset year
rolling, window(20): summarize laseason
list in 1/30
twoway scatter mean start

* version is now a prefix
use http://www.ats.ucla.edu/stat/stata/seminars/svy_stata_intro/oscs1, clear
version 8.2:  svyregress api00 awards meals
* using two prefixes
* Note that the order of the prefixes matters.
xi: svy: regress api00 i.cname growth


How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California