Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

RE: st: Y standardization in ologit regressions with -mi-


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   RE: st: Y standardization in ologit regressions with -mi-
Date   Tue, 7 Dec 2010 16:24:21 +0000 (GMT)

--- On Tue, 7/12/10, Maarten buis wrote:
> I am guessing that you ran my example line by line. This
> example contains local macros (in this case a name for a 
> scalar created by -tempname-), and these cease to exist
> at the end of a session. 

Just to give you a bit more background. The key part of 
the code that gives you trouble is:

tempname sd_y
scalar `sd_y' = 0

I could instead have writen:

scalar sd_y = 0

There are two reasons why I did not do it:

1) The real reason is that it is my habit. I write programs
in Stata. I do not want my programs to overwrite stuff that 
is in the users data (they would _not_ be happy if it did),
and I do not want my programs to leave unnecesary clutter 
behind once it is finished. -tempname- and -tempvar- are 
very useful tools for achieving those aims. It is so useful
that I use it all the time without even thinking about it.

2) the smart reason is that scalars and variables share the
same namespace, and that variables take precedence, even 
abreviated variable names. Say you have a scalar names "a" 
and a variable named "apple". If you typed -di a- you will
get the value of the first observation of the variable apple
rather than the content of the scalar a. You could type
-di scalar(a)- but that is more typing. The trick with 
-tempname- avoids this problem, it creates a unique name for
my scalar that will not clash with any variable names.

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index