Announcement

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

  • A question in "encode"

    Hello, I have a question about "encode". Why the "encode" don't present "English dummy" by defined.
    I use STATA 14

    ///
    webuse hbp2, clear
    tostring city, gen(ncity)
    label define stata 1 "USA" 2 "JAPEN" 3 "UT" 5 "pp"
    encode ncity, gen(stata)

  • #2
    In addition, the number of dummy is wrong.

    /////
    webuse hbp2, clear
    tostring city, gen(ncity)
    label define stata 1 "USA" 2 "JAPEN" 3 "UT" 5 "pp"
    encode ncity, gen(stata)
    recode stata (1=1), gen(new1)

    Comment


    • #3
      Code:
      encode ncity, gen(stata) label(stata)
      may be what you seek.

      Comment


      • #4
        It still can't work

        webuse hbp2, clear
        tostring city, gen(ncity)
        label define stata 1 "USA" 2 "JAPEN" 3 "UT" 5 "pp"
        encode ncity, gen(stata) label(stata)
        recode stata (1=1), gen(new1)

        Comment


        • #5
          Hello, I find a simple way can solve it
          use "recode"
          webuse hbp2, clear
          recode city (1=1 "USA") (2=2 "JPEN") (3 = 3 "UT") (5 =5 "pp"), gen(new1)

          Comment


          • #6
            I am not clear what you seek then. Is it something to do with dummy (=indicator, binary, dichotomous, zero-one) variables?

            Comment


            • #7
              recode does not seem necessary:

              Code:
              label define stata 1 "USA" 2 "JPEN" 3 "UT" 5 "pp"
              label values city stata

              Comment

              Working...
              X