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]

st: Question about scalars


From   Steve Samuels <[email protected]>
To   [email protected]
Subject   st: Question about scalars
Date   Mon, 9 Aug 2010 13:57:56 -0400

In the code below, I generate a scalar "d" from a regression result;
it looks okay, but trying to add it to another scalar doesn't work.
If, however I use a -tempname- , I get the right answer.  Could
someone explain to me why the first approach doesn't work and if
there's another approach that doesn't involve a -tempname-?

Thanks,

Steve

******************************
clear
scalar drop _all
scalar a = 10
scalar b = 20
scalar c = b + a
scalar dir

sysuse auto, clear
reg mpg foreign
scalar d = _b[foreign]
scalar e = d + a
scalar dir a d e // "e" is wrong

tempname dd
scalar `dd' = _b[foreign]
scalar e = `dd' +a
scalar dir a `dd' e // "e" is /okay
****************************

-- 
Steven Samuels
[email protected]
18 Cantine's Island
Saugerties NY 12477
USA
Voice: 845-246-0774
Fax:    206-202-4783

*
*   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