Announcement

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

  • Destring to decimal numerical variable

    I am trying to destring a variable to one decimal numerical variable

    but when I run this command: destring weight , gen (weight1)

    I get this error "weight: : contains nonnumeric characters; no generate"


    Help please. Thanks in advance.

    Code:
    *Example generated by -dataex-. To install: ssc install dataex
    clear
    input str10 weight
    "12.6"
    "14.0"
    "12.7"
    "11.90"
    "12"  
    "13.1"
    "13.6"
    "14.31"
    "15.1"
    "13.2"
    "13.90"
    "13.6"
    "15.5"
    "14.5"
    "13.8"
    Last edited by Adrian Shaba; 15 Jan 2019, 13:46.

  • #2
    the example shown above works fine for me; maybe you should try:
    Code:
    ta weight if real(weight)==.

    Comment


    • #3
      Originally posted by Rich Goldstein View Post
      the example shown above works fine for me; maybe you should try:
      Code:
      ta weight if real(weight)==.
      It gives me this? what does this mean

      Code:
          weight  |      Freq.     Percent     Cum.
      ------------+------------------------------------------
       9.30.319 |          1        100.00      100.00
      ------------+------------------------------------------
             Total |          1        100.00

      Comment


      • #4
        It likely means you have one observation where the weight is given as "9.30.219". You need to correct that value, or remove the observation from your dataset. You can use Stata's data editor to view and edit this observation if you like.
        Code:
        edit if weight=="9.20.919"
        In case it's unclear, the command ta is an abbreviation for the command tabulate.

        Comment


        • #5
          Originally posted by William Lisowski View Post
          It likely means you have one observation where the weight is given as "9.30.219". You need to correct that value, or remove the observation from your dataset. You can use Stata's data editor to view and edit this observation if you like.
          Code:
          edit if weight=="9.20.919"
          In case it's unclear, the command ta is an abbreviation for the command tabulate.

          Well I know that thanks. But after tabulating the entire variable " tab weight" this value can not be seen.

          This has still not resolved my problem.

          Comment


          • #6
            If you changed that rogue value to something else, then it won't now be visible. Otherwise #5 does not help us either. Try destring again and #2 again.

            Comment


            • #7
              Apologies, there is an obvious typo in my post #5. Also, it is possible that the incorrect value has leading or trailing spaces or other unprintable characters. Try instead
              Code:
              edit if real(weight)==.
              Last edited by William Lisowski; 16 Jan 2019, 05:12.

              Comment

              Working...
              X