Announcement

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

  • #16
    Just a cautionary note: encode will work for categorical variables. In case you have numbers stored as strings, e.g., a count of the number of people in a household, see

    Code:
    help destring
    instead.

    Comment


    • #17
      Originally posted by Andrew Musau View Post
      Just a cautionary note: encode will work for categorical variables. In case you have numbers stored as strings, e.g., a count of the number of people in a household, see

      Code:
      help destring
      instead.
      I tried the destring command, using the code below but it stated that it is a nonnumerical character and no generate. What is the function of my codebook at this point? Because I created a code book and is on my data file too. What should I do.


      Code:
      destring gender, generate(Gender)

      Comment


      • #18
        Gender is a categorical variable. With 2 levels, you will usually code it as a 0/1 indicator and rename it using the positive category (e.g., female=1 if gender is female and zero if gender is male). So encode is fine. You will want to only destring numbers which are stored as strings.

        Comment


        • #19
          Originally posted by Andrew Musau View Post
          Gender is a categorical variable. With 2 levels, you will usually code it as a 0/1 indicator and rename it using the positive category (e.g., female=1 if gender is female and zero if gender is male). So encode is fine. You will want to only destring numbers which are stored as strings.
          This is helpful, thanks.

          Comment

          Working...
          X