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, is already up and running.

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

Re: re: st: Package -r2c- now available in SSC

From   Maarten Buis <>
Subject   Re: re: st: Package -r2c- now available in SSC
Date   Tue, 5 Feb 2013 20:38:07 +0100

On Tue, Feb 5, 2013 at 7:46 PM, Nick Cox wrote:
> I note in passing that -r2c- evidently feels free to use the variable names
> mu mumean wt _est_full counts alpha
> so that it will -drop- any previous instances and then overwrite them
> with new ones. This is not documented so far as I can see. Correct me
> if I am wrong, such practices are widely regarded as dangerous Stata
> programming style. Some of these names look highly likely to appeal to
> people fitting count models.

To add to this: the typical way in which this is circumvented is to
use temporary variables. So you would do something like:

tempvar mu mumean wt _est_full counts alpha
gen `mu' = ...
egen `mumean' = ...

the variables `mu' , `mumean', etc. (notice the -`- and the -'-, they
are necesary) will have unique names that do not exist in your data,
they will exist as long as the program runs and will be deleated when
the program ends. That way you do not change the data (unless the user
explicitly asks for it), which is typically considerd good practice in
this community.

-- Maarten

Maarten L. Buis
Reichpietschufer 50
10785 Berlin
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index