Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

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

From   "Daniel Escher" <>
To   <>
Subject   RE: st: Y standardization in ologit regressions with -mi-
Date   Tue, 7 Dec 2010 11:30:07 -0500

Very good to know. I have been using Stata for about 18 months and need to begin learning "advanced" techniques (i.e., loops and macros), so this is a good start. 

-----Original Message-----
From: [] On Behalf Of Maarten buis
Sent: Tuesday, December 07, 2010 11:24 AM
Subject: RE: st: Y standardization in ologit regressions with -mi-

--- 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 L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen


*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index