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

st: RE: label value (continued)


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: label value (continued)
Date   Mon, 29 Sep 2003 12:03:11 +0100

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
n.j.cox@durham.ac.uk

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