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: scalar and others...


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: scalar and others...
Date   Sun, 3 Jun 2012 15:18:11 +0100

On Sun, Jun 3, 2012 at 2:21 PM, tashi lama <[email protected]> wrote:

>    I am reading An Introduction to Stata Programming.

Credit where credit is due to Kit Baum: see

http://www.stata.com/bookstore/stata-programming-introduction/


> I came across with this thing and I am not too sure I understood.
>
> 1. the author recommends using built in functions to interpreted codes like egen. Could someone tell me what is an interpreted code and how is it different from built in codes like generate and replace?

I imagine Kit recommended using built-in commands as well as
functions. (In Stata functions and commands are disjoint.)
Interpreted code reveals itself as written in yet more Stata. A
working definition of built-in commands is that there is no .ado file
for users to look at. Such code is written in C and/or Mata.
-viewsource- lets you look at official and user-written interpreted
code.

> 2. I read somewhere(sorry for vaguness) that  scalar is global in scope yet the book doesn't mention about it while describing scalar. I guess my question is if scalar is local or global in scope?

Neither as such. If you assign a temporary name to a scalar it
disappears at the end of the program you run. Otherwise scalars are
global in scope. In this sense scalars resemble variables.

This is a good question, but also one you can settle for yourself by
experiment. In a do-file editor window type this

scalar tasha = 42
tempname lama
scalar `lama' = 42^2
scalar li

Now in the main interactive session, type

scalar li

-tasha- is visible outside the do-file editor contents, but `lama' is
temporary and visible only while the do-file editor commands are being
executed.

Nick

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