Bookmark and Share

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


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

RE: st: RE: RE: scalar do not allow -if-


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: RE: RE: scalar do not allow -if-
Date   Wed, 17 Nov 2010 16:39:17 +0000

I agree in terms of my own programming. 

The original question was focused on saving scalars as results, in which case temporary names that disappear when a program has finished are of no use. 

There is a middle way. Within a -program- (declared as such) use temporary names for scalars as here, and then when all is done use -return- or -ereturn- to define scalars as r() or e() class results. 

A broader discussion is accessible at 

SJ-6-2  dm0021  . Stata tip 31: Scalar or variable? Problem of ambiguous names
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  G. I. Kolev
        Q2/06   SJ 6(2):279--280                                 (no commands)
        tips for avoiding abbreviation conflicts with variables
        when naming scalars

Nick 
[email protected] 

Maarten buis

--- Nick wrote:
> the code here optimistically assumes no clash between scalar
> and variable names. 
>
> Wrapping with -scalar()- means being always safe and never
> sorry. 

An alternative solution that I often prefer (mostly because 
I am used to it) is:

tempname w1 w2 w3
scalar `w1' = ...
scalar `w2' = ...
scalar `w3' = ...


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