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: re: st: Package -r2c- now available in SSC


From   Simon Falck <simon.falck@abe.kth.se>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   RE: re: st: Package -r2c- now available in SSC
Date   Tue, 5 Feb 2013 20:07:56 +0000

Thanks  Nick and Maarten for your insights on the -r2c-. Very good comments and suggestions.

Simon


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Maarten Buis
Sent: den 5 februari 2013 20:38
To: statalist@hsphsun2.harvard.edu
Subject: Re: re: st: Package -r2c- now available in SSC

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' = ...
etc.

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
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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