Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stata byte values

    In the auto.dta data set, the variable "foreign" is of type "byte" and has value 0 or 1. The command "list foreign" however, displays the words "domestic" or "foreign" that match with the 0s and 1s. How would I program something like that in an .ado file? (i.e. storing an array of distinct integers in e() or r(), but having them displayed as strings when using commands like "list")

  • #2
    -help label-. In particular look at -label define- and -label values-. For the specific instance:

    Code:
    label define foreign 0 "Domestic" 1 "Foreign"
    label values foreign foreign
    Note that value labels like this can only be applied to variables in the data set. You cannot "label" the scalars that get returned in e() or r(). In any case, you also cannot -list- things from e() and r() either, you can only -list- variables. Similarly, if by "array" you mean matrix, you cannot label the values in a Stata or Mata matrix either. So I'm not entirely sure what you're asking for here. Perhaps a specific example of what you'd like to do would clarify.

    Comment

    Working...
    X