Announcement

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

  • Non numeric Characters in data set

    I am facing a problem in destring command while running it as my data set contains X00,X99,X10 values and other values are numeric. I am getting following result
    destring nco2004, replace
    nco2004 contains nonnumeric characters; no replace
    Can you help sir with this problem? nco2004 is variable name

  • #2
    Using the term "sir" is not a good idea: this is not a club for males only.

    So, you need to find the non-numeric characters that are problematic.

    Code:
    tab nco2004 if missing(real(nco2004))
    and then and only then can there be a diagnosis of

    1. whether destring is the right command any way

    2. if it is, which options to use (see help destring)

    For more see e.g. http://www.statalist.org/forums/foru...iable-problems

    Comment


    • #3
      Thank you , I get it and got the result.

      Comment


      • #4
        This is a similar thread :http://www.statalist.org/forums/foru...meric-variable

        There, some options to tackle the problem were commented, such as "force" and "ignore".

        But the reason I share it here is that Nick's command in #2 provides a (much) more elegant solution.
        Best regards,

        Marcos

        Comment


        • #5
          I am having a similar issue. I have a variable label called LeftKneeAlignment in a dataset called Joints. The variable label is currently a string variable but its meant to be all numerical values ranging from -16 to +23. In the variable list there are values that are non-numeric "N", "P", and "Z" which I am trying to ignore. The data is below:

          Freq. Percent Cum.
          ------------+-----------------------------------
          -1 | 372 12.29 12.29
          -10 | 31 1.02 13.32
          -11 | 14 0.46 13.78
          -12 | 7 0.23 14.01
          -13 | 4 0.13 14.14
          -14 | 5 0.17 14.31
          -15 | 9 0.30 14.61
          -16 | 4 0.13 14.74
          -18 | 4 0.13 14.87
          -2 | 342 11.30 26.17
          -20 | 1 0.03 26.21
          -21 | 1 0.03 26.24
          -3 | 284 9.39 35.62
          -4 | 244 8.06 43.69
          -5 | 155 5.12 48.81
          -6 | 132 4.36 53.17
          -7 | 77 2.54 55.72
          -8 | 63 2.08 57.80
          -9 | 40 1.32 59.12
          0 | 363 12.00 71.12
          1 | 259 8.56 79.68
          10 | 5 0.17 79.84
          11 | 3 0.10 79.94
          12 | 3 0.10 80.04
          14 | 1 0.03 80.07
          15 | 1 0.03 80.11
          2 | 209 6.91 87.01
          3 | 131 4.33 91.34
          4 | 59 1.95 93.29
          5 | 41 1.35 94.65
          6 | 27 0.89 95.54
          7 | 15 0.50 96.03
          8 | 9 0.30 96.33
          9 | 7 0.23 96.56
          N | 41 1.35 97.92
          P | 10 0.33 98.25
          Z | 53 1.75 100.00
          ------------+-----------------------------------
          Total | 3,026 100.00

          I am trying to categorise the dataset into 3 categories.

          so <-2 = varus
          -2 to +2 = neutral
          >+2 = valgus

          I have tried to ignore the "P,N and Z" and then categorise the remaining dataset by doing the following:

          recode LeftKneeAlignment (min/-2=Varus) (-2/2=Neutral) (2/max=Valgus) ignore "N" "P" "Z"

          But it keeps saying recode only allows numeric variables

          Grateful for any help

          Comment


          • #6
            the "ignore" option goes with the -destring- command; see
            Code:
            help destring
            after that you can use -recode- but you are not using that correctly so also see
            Code:
            help recode

            Comment

            Working...
            X