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

RE: st: RE: a "byable" cii


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: a "byable" cii
Date   Fri, 7 Feb 2003 09:37:28 -0000

Vince Wiggins,

> 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' {
>             ...
 

Quite right, except that last line should be 

       forvalues j = 1/`=_N' {


Nick 
[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