Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: RE: tabstat: how to save...


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: RE: tabstat: how to save...
Date   Wed, 10 May 2006 12:47:13 +0100

No, on this detail you are wrong and version
is not an issue. 

So long as you follow my example and issue 

tempname foosum

then after 

su foo, meanonly 

scalar `foosum' = r(sum) 

is as valid as can be. 

You are correct that you can do what
looks the same thing by 

sum foo, meanonly 
scalar foosum = r(sum) 

but to do that is to live more dangerously. 
If you do this, sooner or later you will
get burned, or bitten, by use of the same name in 
different programs or use of identical
or similar names for scalars and variables.

The problem is aired in the manuals and 
rehearsed once more in a Tip by G. Kolev
in Stata Journal 6(2), to appear next
month. 

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

b. water
 
> Thank you Nick for your alternative suggestion. 
> 
> In Stata 8.2, scalar `foosum' = r(sum) is an invalid syntax 
> but checking on-line help showed valid syntax as scalar 
> foosum = r(sum). This suggestion worked for my purpose and as 
> you alluded, shorter than tabstat.
 
Nick Cox
  
> > > note that if the problem 
> > > is picking up a sum for future use, then -tabstat- is 
> > > a long way round. 
> > > 
> > > tempname foosum 
> > > su foo, meanonly 
> > > scalar `foosum' = r(sum) 
> > > 
> > > is more direct, with no hidden interpreted code, 
> > > as in -tabstat-. 

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