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

Re: st: RE: a "byable" cii


From   vwiggins@stata.com (Vince Wiggins, StataCorp)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: a "byable" cii
Date   Thu, 06 Feb 2003 17:12:02 -0600

Just a quick followup to Nick Cox's <n.j.cox@durham.ac.uk> solution of
Paul Visintainer's <visint@nymc.edu> 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 
   vwiggins@stata.com

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index