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

Re: st: RE: a "byable" cii

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

Just a quick followup to Nick Cox's <> solution of
Paul Visintainer's <> 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

*   For searches and help try:

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