Announcement

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

  • #16
    Jorrit:

    Sure

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double hhcode long count int(street group)
    31010101420086 310101 14 13
    31010101420086 310101 14 13
    31010101420086 310101 14 13
    31010101420299 310101 14 13
    31010101420299 310101 14 13
    31010101420299 310101 14 13
    31010101420354 310101 14 13
    31010101420354 310101 14 13
    31010101420354 310101 14 13
    31010101420762 310101 14 13
    31010101420762 310101 14 13
    end
    label values hhcode hhcode
    label values count count
    label values street street
    label values group group
    I'm don't know how to remove the value label of this variable. And I don't know what it means that a variable has a value label. This data is survey data.

    Comment


    • #17
      Still a bit funny. The value label appears empty, at least on my side. In fact all of the value labels included with your sample do.
      How were these value labels created?

      What do you get when you type
      Code:
      label list

      Comment


      • #18
        Jorrit:

        I don't know how these value labels were created. I'm simply trying to use this survey data. This is what I get when I type
        Code:
        label list
        Code:
        label list
        _merge:
                   1 master only (1)
                   2 using only (2)
                   3 matched (3)
                   4 missing updated (4)
                   5 nonmissing conflict (5)
        c11:
                   1 Agriculture, Forestry, Animal husbandry
                   2  Mining
                   3 Manufacturing
                   4 Production and Supply of Electricity, Gas and Water
                   5 Construction Enterprise
                   6 Transport, Storage and Post Industry
                   7 Information Transmission, Computer Services and Software Industry
                   8 Wholesale and Retail Trade
                   9 Hotel and Catering Services
                  10 Financial Intermediation
                  11 Real Estate Industry
        The list is very long but does not include the variable hhcode. Could it be possible that Stata believes that hhcode has a value label while it doesn't?

        Thanks!
        Last edited by Candice Yandam; 10 Mar 2017, 01:42.

        Comment


        • #19
          Well, more precise you could do
          Code:
          label list hhcode
          If that returns ''value label hhcode not found" then its just an empty label here (i.e., no label values defined).

          What i woudl do is.
          Code:
          ren hhcode hhcodeold
          tostring hhcodeold, gen(hhcode)format("%14.0f")
          This saves a copy of the original if you ever want to go back. Labels are not copied over when creating a new var like this.
          Last edited by Jorrit Gosens; 10 Mar 2017, 02:06.

          Comment


          • #20
            If hhcode was a previously encoded variable, then you have to go back to the original values.

            Comment


            • #21
              I wondered about that being the origin of the label, but it didnt seem likely that this would create values in the range of 31010101420086.
              Or is it?

              Comment


              • #22
                Jorrit: I agree; that sounds unlikely.

                Comment


                • #23
                  Jorrit:

                  Yes, hhcode had just an empty label.
                  I followed your suggestion and it worked! Many thanks!

                  Nick:

                  hhcode is encoded as "double" in the 2007 dataset but a string in the 2013 dataset.

                  Comment


                  • #24
                    Basically, part of the identifier refers to the county code, then street, and then individual id of the household which makes a 14 integers long number/identifier.

                    Comment


                    • #25
                      Alright.
                      Note that if you were entirely certain the label was not needed you could also do:
                      Code:
                      tostring hhcode, replace format("%14.0f") force
                      The suggestion to copy over the variable first is just a precaution against throwing away info from a dataset I am not familiar with and could only see a small part of.

                      Comment


                      • #26
                        Jorrit:

                        I understand, and I will keep this precaution just in case. Thanks!

                        Thank you all very much for your help

                        Comment

                        Working...
                        X