Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: Nested locals?


From   Neil Shephard <nshephard@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Nested locals?
Date   Mon, 8 Jun 2009 09:41:36 +0100

On Fri, Jun 5, 2009 at 5:52 PM, Nick Cox<n.j.cox@durham.ac.uk> wrote:
> Focusing on this code:
>
>  local n = r(k)
>  forval x = 1/`n'{
>        local _`x' `r(c`x')'
>        di `"_`x'"'  // <-- In so I can see if I'm getting it right!
>   }
>
> Note that once you have defined (e.g.) the local macro with name _1, you
> need to refer to the whole of its name within within ` '.
>
> So try
>
>  local n = r(k)
>  forval x = 1/`n'{
>        local _`x' `r(c`x')'
>        di `"`_`x''"'
>   }
>
> The surrounding c.d.q. `" "' are quite independent of de-referencing any
> local macros referred to within. `" and "' are both composite symbols
> and the fact that they contain ` and ' has no connection to macro
> syntax.

Ahh, I get it now, thank you very much for enlightening me Nick,

Cheers

Neil


-- 
"The combination of some data and an aching desire for an answer does
not ensure that a reasonable answer can be extracted from a given body
of data." ~ John Tukey (1986), "Sunset salvo". The American
Statistician 40(1).

Email - nshephard@gmail.com
Website - http://slack.ser.man.ac.uk/
Photos - http://www.flickr.com/photos/slackline/

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