Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: svy bootstrap


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: svy bootstrap
Date   Wed, 9 Mar 2011 09:09:58 +0000

That looks like a clue to me.

-syntax- is seeing nothing that it recognises as a varlist.

More seriously, you are dropping a -program- called -model1- but then
not redefining it. -syntax- looks for a macro named 0, and if it can't
find one it tries to parse an empty string. An empty string can't
include a varlist.

You do the right thing by -program twopart- which defines a program.
You also need -program define model1- and the same for -model2-. (The
"define"s are optional since Stata 8; I include them here to stress
what -program- does in that case.)

When you run a -program- local macro 0 is created for you as the
program arguments. But if you run -syntax- by itself, which is
perfectly legal, it does need a macro 0 to exist.

Nick

On Wed, Mar 9, 2011 at 8:01 AM, Michael Palmer
<[email protected]> wrote:
> Many thanks, I have written two separate programs for each syntax to run within the main program.
> Stata stops at the `syntax varlist [pweight]' line with the error message 'varlist required'.
> Any clues? Tomorrow is another day, hopefully I'll figure it out.
>
> svyset [pweight=psindwt], strata(domain) psu(commcode)
> set trace on
> set more off
>
> capture program drop model1
> tempvar pr_y
> syntax varlist [pweight]
> quietly logit `varlist' `weight'
> quietly predict `pr_y', pr
> end
>
> capture program drop model2
> tempar yhat ehat
> syntax varlist [pweight]
> quietly regress `varlist' `weight'
> quietly predict `yhat', xb
> quietly predict `ehat', res
> end
>
> capture program drop twopart
> program twopart, rclass
> tempname sm1 sm0 m_1 m_2 m_3 m_4
> tempvar pr_y yhat ehat smear smear_ins sm1 smear_noins sm2 yhat_duan yhat_pwd1 yhat_pwd0 y_pwd1 y_pwd0
> do model1.do
> model1 inpat_public $xlist1 if age > 5
> do model2.do
> model2 ipexp_public_log $xlist1 if age > 5 & inpat_public==1
>
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index