In order to help you, we need to know more about your problem:
- which line is causing you grief? (We can't simply guess which one it is.)
- if you don't know which line Stata is choking on, you need to -set trace
on-, create a log of a sample run of your program, and then paste it in one
of your message. (I mentioned this yesterday.)
- don't send us just part of you program. (Again, we can't guess what some
of your macros contain. And, again, I mentioned this yesterday.)
Sometimes errors may be obvious to us, but you can't just assume that. Help
us help you if you want any help at all.
Patrick Joly
[email protected]
[email protected]
> -----Original Message-----
> From: Anna-Lisa Pierre [mailto:[email protected]]
> Sent: June 07, 2002 10:30 AM
> To: [email protected]
> Subject: st: tempvar
>
>
> Hi
>
> I am trying to use the 'tempvar' command so that I do not
> have to drop
> variables at the end. However, I am having problems using
> this within loops.
> Are 'tempvar' and 'tempname' not supposed to be used within
> loops? The part
> of my programme that is giving trouble is as follows:
> Any insights will be gratefully appreciated.
>
> tempvar wj_1 phiwj_1 PHIwj_1 diffqq2;
> while `j' <= `depmax' { ;
>
> local xless1 = `x'-1 ;
>
> if `j' < `depmax' { ;
> ge `diffqq2' = ( normprob(_b[_cut`x']-`scor_uqq') -
> normprob(_b[_cut`x']-`scor_nqq') )
> - ( normprob(_b[_cut`xless1']-`scor_uqq') -
> normprob(_b[_cut`xless1']-`scor_nqq') )
> if `1'~=. ;
> } ;
> else { ;
> ge `diffqq2' = normprob(`scor_uqq'-_b[_cut`xless1']) -
> normprob(`scor_nqq'-_b[_cut`xless1']) if `1'~=. ;
> } ;
>
>
> su `diffqq2' `if' ;
> local diff`x' = r(mean) ;
> scalar `check' = `check' + `diff`x'' ;
>
>
> rename `wj' `wj_1' ;
> rename `phiwj' `phiwj_1' ;
> rename `PHIwj' `PHIwj_1' ;
>
> if `j'~=`depmax' { ;
> ge `wj' = ( _b[_cut`x'] - `scoreqq' ) `if' ;
> ge `phiwj' = (1/sqrt(2*_pi)) * exp( (`wj'^2)/-2 ) `if' ;
> ge `PHIwj' = normprob(`wj') `if' ;
> } ;
> else { ;
> ge `wj' = 0 ;
> ge `phiwj' = 0 ;
> ge `PHIwj' = 1 ;
> } ;
>
> replace `eqq'=( `phiwj_1' - `phiwj' ) / ( `PHIwj' -
> `PHIwj_1' ) if `1'==`j'
> & `ifexp' ;
> replace `e2qq'=( (`wj_1' * `phiwj_1') - (`wj' * `phiwj') )
> / ( `PHIwj' - `PHIwj_1' ) if
> `1'==`j' & `ifexp' ;
> replace `e3qq'=( ((`wj_1'^2) * `phiwj_1') - ((`wj'^2) *
> `phiwj') )
> / ( `PHIwj' - `PHIwj_1' ) if
> `1'==`j' & `ifexp' ;
> replace `e4qq'=( ((`wj_1'^3) * `phiwj_1') - ((`wj'^3) *
> `phiwj') )
> / ( `PHIwj' - `PHIwj_1' ) if
> `1'==`j' & `ifexp' ;
>
>
> tempvar y`x'iqq y`xless1'iqq;
> if `j'~=`depmax' { ;
> capture drop `y`x'iqq' ;
> if _rc == 0 { local dropvar="`dropvar' `y`x'iqq`" } ;
> ge `y`x'iqq' = 0 `if' ;
> replace `y`x'iqq'=( `phiwj' ) / ( `PHIwj' -
> `PHIwj_1' ) if `1'==`j' &
> `ifexp' ;
> } ;
>
> if `x'~=2 { ;
> replace `y`xless1'iqq'=( -1 * `phiwj_1' ) / (
> `PHIwj' - `PHIwj_1' )
> if `1'==`j' & `ifexp' ;
> } ;
> su `1' if `1'>`j' & `ifexp' ;
> local j = r(min) ; /* replace j with next value of
> dep var */
> local x=`x'+1 ;
> drop `wj_1' `phiwj_1' `PHIwj_1' ;
> } ;
>
>
> #delimit cr
>
> _________________________________________________________________
> Join the world's largest e-mail service with MSN Hotmail.
> http://www.hotmail.com
>
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/