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

st: RE: scalar troubles?


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: scalar troubles?
Date   Wed, 5 Nov 2003 14:04:42 -0000

A guess: If you have a variable -m1- then 

di m1 

will be interpreted as 

di m1[1] 
 
rather than 

di scalar(m1) 

The binding -scalar()- is needed in cases of ambiguity. 

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

Edwin Leuven
 
> running one of my ado's i get the following table
> 
> -----------------------------------------------------------------
>                          |         Mean                   % reduct
>      Variable     Sample |  Treated   Controls   % bias     |bias|
> ------------------------+----------------------------------------
>         Ltaal  Unmatched |        0   -.547782    118.0
>                  Matched |-.7002011  -.6988459     -0.3       99.8
> -----------------------------------------------------------------
> 
> the unmatched mean among the treated should not be zero however
> 
> the piece of code that calculates it is simply
> 
>          qui sum `v' if `treated'==1
> 
> which gives, when i remove the -qui-, the following
> 
>      Variable |       Obs        Mean    Std. Dev.       
> Min        Max
> -------------+----------------------------------------------
> ----------
>         Ltaal |       296   -.7002011    .4792868  
> -2.157421    .846165
> 
> then i do this
> 
>          scalar m1 = r(mean)
>          scalar v1 = r(Var)
> 
> and adding this as a check:
> 
>          di m1
> 
> gives
> 
> 0
> 
> !!
> 
> if i change the name of the scalar to m1x, everything works 
> fine, ie the 
>   0 becomes -.7002011
> 
> i am baffled...
> 

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