Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: a "byable" cii


From   [email protected] (Vince Wiggins, StataCorp)
To   [email protected]
Subject   Re: st: RE: a "byable" cii
Date   Thu, 06 Feb 2003 17:12:02 -0600

Just a quick followup to Nick Cox's <[email protected]> solution of
Paul Visintainer's <[email protected]> problem on repeating calls to -cii- for
many observations.  Nick suggested,


>       forval i = 1/100 { 
>             local n = num[`i'] 
>             local d = den[`i'] 
>             cii `d' `n' 
>       } 

In Stata 8, we collapse the three lines in Nick's loop into one,

      forval i = 1/100 { 
            cii `=num[`i']' `=den[`i']'
      } 

The new local macro expansion directive `= ...' causes whatever lies between
the = and the closing quote (') to be evaluated as an expression and its
result placed in the command.  This can be convenient when you want to
evaluate an expression, or fetch a value that is only available in an
expression context, in a place where the command wants to see a numeric or
string literal.  I rarely use the directive to evaluate long expressions, but
it can be convenient for short ones.  

Another common usage might be,


      forvalues j = 1/`_N' {
            ...


-- Vince 
   [email protected]

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index