Announcement

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

  • #16
    As said, these encoded values in TA and debt_n are no use for calculations. You need to destring the original string variables ignoring the commas and any other non-numeric characters. #11 is still the advice. The debt string variable is evidently debt; I don't think anything in the thread tells us what preceded TA.

    Comment


    • #17
      Thanks a lot, and appreciate your help.

      Comment


      • #18
        A postscript addressed to anyone who encounters this topic while seeking a solution to a similar problem.

        The value labels shown in post #15 confirm that the variables were converted from strings with commas and other non-numeric characters into numbers using the encode command. Note that the values assigned to each numeric variable do not match the values shown in the original string. The describe command would also show that they were numeric variables with value labels.

        The encode command is designed for assigning numerical codes to non-numeric strings like "France", "Germany", "United States". The output of help encode instructs us

        Do not use encode if varname contains numbers that merely happen to be stored as strings; instead, use generate newvar = real(varname) or destring; see real() or [D] destring.

        Comment


        • #19
          Thank you!
          But, is there any way to convert the current format of the variable (TE) to numeric as I don't have the its original format within this dateset!

          Code:
          . des TE
          
                        storage   display    value
          variable name   type    format     label      variable label
          ---------------------------------------------------------------------------------------------------------------------------------------------------------------
          TE              int     %17.0g     TE
          Last edited by Hamza Almustafa; 06 Feb 2022, 09:24.

          Comment


          • #20
            I advise you to go back to your original dataset and start there, rerunning the code that created the encoded numeric values of TE and other variables, correcting your encode commands to the appropriate destring commands.

            You made at least one set of errors by converting numeric variables using encode rather than destring; there may well have been subsequent code that did not function as you think it did because of the incorrect values of the numeric variables.

            There is an alternative but I feel strongly enough about this that I will leave it to someone else to explain it, or for you to figure out from the documentation how to create string variables using your encoded values, that you can then apply destring to.
            Last edited by William Lisowski; 06 Feb 2022, 09:26.

            Comment


            • #21
              I agree with @William Liswowski https://www.stata-journal.com/articl...article=dm0098 offers an overview, including yet more explanation of why destring not encode is what you need.

              Comment


              • #22
                Thanks, and appreciate your collaboration.

                Comment

                Working...
                X