Announcement

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

  • r199; command is unrecognized

    Hello everybody, i have a question.

    I've got a dataset with 3 nonnumeric string- variables. First i tried to convert the nonnumveric variables to numeric string variables and afterwards use the destring command... see here:

    CODE:::

    . **Preparing Dataset
    .
    . *2002
    .
    . *Missing Values
    .
    . use "E:\Stata\data\tAHS2002m.dta", clear

    . keep smsa tenure nunit2 built cellar garage floors unitsf value weight

    .
    . replace garage="." if garage=="'-6'"|garage=="'-7'"|garage=="'-8'"|garage=="'-9'"
    (11,411 real changes made)

    .
    .
    . *Convert Nonnumeric String Variable to numeric string variable
    .
    . *Install
    . ssc install egenmore
    checking egenmore consistency and verifying not already installed...
    all files already exist and are up to date.

    . ssc install ereplace
    checking ereplace consistency and verifying not already installed...
    all files already exist and are up to date.

    .
    . *for Variable garage
    . ereplace garage = sieve(garage), keep(numeric)
    (11411 missing values generated)
    (65,516 real changes made)

    .
    . *for Variable tenure
    . *ereplace tenure = sieve(tenure), keep(numeric)
    .
    . *for Variable nunit2
    . ereplace nunit2 = sieve(nunit2), keep(numeric)
    (65,516 real changes made)

    .
    .
    . *convert string variable to numeric variable
    .
    . destring garage, replace
    garage has all characters numeric; replaced as byte
    (11411 missing values generated)

    . nunit2 has all characters numeric; replaced as byte
    command nunit2 is unrecognized
    r(199);

    end of do-file

    r(199);

    .

    As soon as i br the data, the variables are shown as byte variables, so why does an error occur?

    Hope anybody can help me...

    Many thanks

  • #2
    Where is the destring command? Try the syntax below and also show the output.

    Code:
    destring nunit2, replace
    Last edited by Anders Alexandersson; 12 Sep 2018, 08:52. Reason: Edit: nunit2 is a variable

    Comment


    • #3
      yes, sorry, anders you're right but there is still an error

      *convert string variable to numeric variable
      .
      . destring garage nunit2 tenure, replace force
      garage contains nonnumeric characters; garage replaced as byte
      (11411 missing values generated)
      nunit2 contains nonnumeric characters; nunit2 replaced as byte
      tenure contains nonnumeric characters; tenure replaced as byte
      (65516 missing values generated)

      . nunit2 has all characters numeric; replaced as byte
      command nunit2 is unrecognized
      r(199);

      end of do-file

      r(199);

      Comment


      • #4
        "Master" Please note our firm and explicit preference for real names.

        https://www.statalist.org/forums/help#realnames

        https://www.statalist.org/forums/help#adviceextras #3

        Otherwise, the force option is there only for if you really know why you're using it. The real question is why you have to use it, which commands like


        Code:
        tab garage if missing(real(garage))
        should make clear. So, what non-numeric characters is what you should be asking.


        Last edited by Nick Cox; 12 Sep 2018, 09:23.

        Comment


        • #5
          Nick i already contacted stata regarding this issue

          Comment

          Working...
          X