Announcement

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

  • How to Un-Encode

    Hi guys,
    Kindly help. I have a data set with encoded distance figures. I would like to reverse the encode so that my distance is back to numeric values. How do I do that?

  • #2
    if these are really encoded, they already are numeric but have value labels; please read the FAQ and provide a -dataex- example as discussed in the FAQ; if you are just using words differently than Stata does see
    Code:
    help decode

    Comment


    • #3
      Perhaps you used the encode command to convert numeric distance values stored as a string variable into a numeric variable suitable for use in calculations. If so, you probably should have used the destring command instead. The output of
      Code:
      help encode
      warns us to not use encode if the variable contains numbers that merely happen to be stored as strings.

      Comment


      • #4
        Thanks for the reply. I have tried the decode command but it's only generating a new variable without entries. Destring cannot work because the data is already numeric.
        So the data came encoded already. Below is an example of what the data is like.

        Distance: 2, 3, 6.7, 9.1, 3, 2.5, 6.4 etc.
        These distance entries are numeric but they have been encoded so each number (distance) is a label.

        I want to reverse this so that I may be able to calculate things like the average distance and even the speed based on this.

        Comment


        • #5
          Descriptions of your data will get you nowhere slowly. You have already been advised in #2 to use the -dataex- command to post an excerpt from your data. If you are running version 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

          So do that. Until you do, it is unlikely anybody will be able to figure out what your data set actually looks like, and so, unlikely anyone will be able to help you.

          In addition, it is the norm in this community to use our real first and last names as our user name, to promote collegiality and professionalism. The Forum software does not allow you to edit your username yourself. But if you click on CONTACT US in the lower right corner of the window, you can message the Forum administrator requesting the change. Please do that.

          Comment

          Working...
          X