Statalist The Stata Listserver

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

Re: st: RE: Local macro & Temp variable with same name?

From   Nick Winter <>
Subject   Re: st: RE: Local macro & Temp variable with same name?
Date   Fri, 17 Mar 2006 13:39:59 -0500


When you issue a command like

tempvar mytemp

What Stata is doing is picking out a variable name for you (something like __000001), and assigning that name to the local macro called mytemp.

So then, whenever you refer to the local macro, as `mytemp', stata is seeing the name __000001 , which refers to your temporary variable.

So if you reassign the local macro -mytemp- to be something else, you will lose access to your tempvar.

But you could have a local macro called __000001 , which you could refer to as `__000001'. That would have no relation to the variable named __000001. (Just as a local macro `mpg' has no relationship to the variable mpg.)

But why?

--NIck Winter

At 01:18 PM 3/17/2006, you wrote:

Have no intention. It just _sounds_ like a bad idea. But I was curious!


National Bureau of Economic Research <>

---------- Original Message -----------
From: "Nick Cox" <>
To: <>
Sent: Fri, 17 Mar 2006 18:10:48 -0000
Subject: st: RE: Local macro & Temp variable with same name?

> Principle 1: Whatever you say last is true.
> Principle 0: In essence, don't do this!
> Nick
> Danielle H. Ferry
> > Will Stata know the difference between a local macro and a
> > temporary variable with the same name?

*   For searches and help try:
Nicholas Winter                           607.255.8819 t
Assistant Professor                       607.255.4530 f
Department of Government     e
308 White Hall   w
Cornell University
Ithaca, NY 14853-4601

*   For searches and help try:

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