Announcement

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

  • Command to find how variables are coded?

    In my data set, variable gender is coded as 0 and 1. Can anyone tell me the command to see whether female is coded as 0 or 1?
    Thanks in advance.

  • #2
    There might be a better way, but I just

    Code:
    tab var
    tab var, nolabel
    and see what matches what. Additionally, if you go to Data -> Variables Manager you can access all your labels, where you can see to which values each label matches to.

    Comment


    • #3
      I tried, but it didn't work

      Comment


      • #4
        Code:
        label list `:value label var'

        Comment


        • #5
          The command that gets you there in one step is -codebook-. Here is an example.

          Code:
          set obs 2
          gen byte gender = _n
          label define cgender 1 "Male" 2 "Female"
          label values gender cgender
          
          codebook gender
          And the abbreviated output of -codebook gender- shows:

          Code:
                      tabulation:  Freq.   Numeric  Label
                                       1         1  Male
                                       1         2  Female
          Notice the direct comparison between the numeric coding and associated labels. If nothing were listed in the Label column, it would mean your numeric variable for gender is missing value labels and you will need to go back to the data source to figure out what 0 and 1 mean.

          Comment


          • #6
            Originally posted by Beenish Amir View Post
            I tried, but it didn't work
            Please explain what's happening. Show your database using dataex - read the FAQ.

            If your variable is coded as 0 and 1 and the variable is not labeled, then this is not something Stata can help you - check with who entered the database, they should know how they coded male and female.

            Comment


            • #7
              Okay, thank you so much

              Comment


              • #8
                Also,

                Code:
                help codebook
                Best regards,

                Marcos

                Comment

                Working...
                X