Announcement

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

  • Dropping value label for a variable

    Hi!

    I have a dataset in stata in which I want to string a numeric variable called bopael.
    When I try to string it with the command:

    tostring (bopael), replace

    I get the error:
    bopael has value label ; no replace

    It has a value label called prog

    I have tried to drop the label value with:
    label drop prog

    Though the value label still appears, which leads to that i'm unable to string my variable.

    Hope you can help!

  • #2
    Do you really want decode?

    Otherwise

    Code:
    gen wanted = strofreal(bopael)
    maps e.g. 42 to "42" is that is what you want, but I doubt it.
    Last edited by Nick Cox; 03 Mar 2020, 06:19.

    Comment


    • #3
      Louise:
      what if you create a -string- alias of -bopael- and then drop -bopael-?:
      Code:
      tostring (bopael), g(new_bopael)
      drop bopael
      Kind regards,
      Carlo
      (StataNow 19.0)

      Comment


      • #4
        I haven't tried to use the decode command, but should that work?

        Comment


        • #5
          Thank you, that works!

          Comment


          • #6
            Getting back to the title:

            Code:
            label drop lblname
            as is documented, will eliminate value label definitions from memory. To detach value labels from a variable, use

            Code:
            label values varname .
            where the dot (.) may be omitted.

            elabel (SSC) has a remove subcommand that combines these two steps.

            Best
            Daniel

            Comment

            Working...
            X