Jean Bouyer
>
> Thanks Nick for your answer. I think I can get by with it. However,
> may I come back to my question in another way, as I think
> that beyond
> it, there is something about macros (or about : label) that I don't
> understand.
>
> I don't understand why this works (where v is a variable
> with a label value)
>
> local n=6
> local ll=v[`n']
> display "`: label (v) `ll''"
>
> and this doesn't
>
> local n=6
> display "`: label (v) v[`n']'"
> (Stata answers invalid syntax)
>
> I have noted also that this doesn't work either
> display "`: label (v) v[6]'"
> (Stata answers invalid syntax)
>
As far as Stata is concerned, in this context
v[6]
is a text string, not a numeric value. The syntax
allows only numeric values in the position (apart from
other possibilities, not relevant here).
It is the difference between (1) a name and (2) the value
stored at the corresponding location.
You want _evaluation_ as well; in
local n=6
local ll=v[`n']
display "`: label (v) `ll''"
the second line evaluates
v[6]
which is why it works.
This also would evaluate:
local n=6
display "`: label (v) `=v[`n']''"
as would this
display "`: label (v) `=v[6]''"
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/