Announcement

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

  • label drop functionality request for StataCorp

    Here is a quick example showing what I believe to be some undesirable behavior (not sure if other Stata users would agree or not) :

    Code:
    sysuse auto.dta, clear
    desc
    la drop origin
    tostring foreign, replace
    la val foreign
    tostring foreign, replace
    Although the label used to associate value labels with the values of the foreign variable gets dropped, internally Stata still treats the variable foreign as though it has a value label associated with it when subsequent commands require the values not be associated with labels. I'd like to suggest that dropping the value label would also disassociate that value label with any variables as well. I can't think of a reason why it would make sense to retain the association between the variable and value label after the value label has been dropped but would definitely be interested to know if there are use cases for doing that. Alan Riley (StataCorp) do you have any thoughts about this?

  • #2
    Originally posted by wbuchanan View Post
    ...

    Although the label used to associate value labels with the values of the foreign variable gets dropped, internally Stata still treats the variable foreign as though it has a value label associated with it when subsequent commands require the values not be associated with labels. I'd like to suggest that dropping the value label would also disassociate that value label with any variables as well. I can't think of a reason why it would make sense to retain the association between the variable and value label after the value label has been dropped but would definitely be interested to know if there are use cases for doing that. Alan Riley (StataCorp) do you have any thoughts about this?

    This behavior is by design. It is described in Example 1 in the [D] label manual entry. The idea is just to have flexibility. Say you have 20 different variables which could all benefit from the same label. You can define the label first and then attach it to all 20, or you can tell Stata that all 20 of them will have a label with the same name, and then define that label when convenient.

    Comment


    • #3
      Alan Riley (StataCorp) I just took a look at the entry that you mentioned. On page 471 the description of the behavior isn't necessarily consistent with the behavior:

      When Stata uses such a variable, it simply acts as if the variable is not labeled:
      If the variable was not labeled, the tostring command should not have an issue recasting the values to a string once the value label is dropped. Maybe the documentation could be a bit more explicit about the behavior (e.g., When Stata displays the values of such a variable, it simply acts as if the values are not labeled? I can see value in being able to attach the same value labels to multiple variables, and could see a possible use for redefining the value labels but it wouldn't be necessary to drop the value label first to do that.

      Comment

      Working...
      X