Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Tempname and Tempvar - help desperately needed


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Tempname and Tempvar - help desperately needed
Date   Wed, 19 Jun 2002 15:36:32 +0100

Miss M Paul
> 
> Can someone advise me as to why the following piece of programme does
> not work? I get the error message "__0000E8 already defined". The
> programme worked fine until I began to use the tempname and tempvar
> commands. I would greatly appreciate any ideas on where/why I have gone
> wrong.
> 
>  #delimit ;
> 
>   tempvar 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'' ;
> 
> 
>  tempvar wj_1 phiwj_1 PHIwj_1;
>  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' ;
>   } ;
> 

This is a message about something temporary which is undefined. 

The only efficient way to debug this is that you 

set trace on 

and then see where it stops. Then insert 
a line 

mac li 

just before and see what is undefined. 


Nick 
n.j.cox@durham.ac.uk 

*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index