--- L S wrote:
> I am having difficulty using the Stata syntax command.
Below is an example that illustrate how you can debug such
programs and at the bottom are two solutions.
*----------------------- begin example ---------------------
clear
set obs 100
set seed 1234
gen y = uniform()
gen x = uniform()
gen z = uniform()
gen clus = (z>.5)
capture program drop toyreg
program toyreg
syntax varlist , CLUSTER(varname)
gettoken y xvars : varlist
di "the local CLUSTER contains: " `"`CLUSTER'"'
di "the local cluster contains: " `"`cluster'"'
reg `y' `xvars', `CLUSTER'
end
toyreg y x, cluster(clus)
// one solution
capture program drop toyreg
program toyreg
syntax varlist , CLUSTER(passthru)
gettoken y xvars : varlist
di "the local CLUSTER contains: " `"`CLUSTER'"'
di "the local cluster contains: " `"`cluster'"'
reg `y' `xvars', `cluster'
end
toyreg y x, cluster(clus)
// another solution
capture program drop toyreg
program toyreg
syntax varlist , CLUSTER(varname)
gettoken y xvars : varlist
di "the local CLUSTER contains: " `"`CLUSTER'"'
di "the local cluster contains: " `"`cluster'"'
reg `y' `xvars', cluster(`cluster')
end
toyreg y x, cluster(clus)
*------------------- end example -----------------------
( For more on how to use examples I sent to statalist see:
http://www.maartenbuis.nl/stata/exampleFAQ.html )
Hope this helps,
Maarten
--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany
http://www.maartenbuis.nl
--------------------------
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/