Announcement

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

  • Tab missing values against another variable

    Hi,

    I have one variable of "ethnicity" which has 203 missing observations. I also have another variable of "yesno" but only 2 obervations "yes and "no". I'm trying to find a way get stata to display how many missing observations of ethnicity are in "yes" and how many are in "no". I'm not sure if this requires more labeling, but I've certainly hit a brick wall. Any help would be massively appreciated!

    Sam
    Last edited by Sam Wang; 06 Dec 2015, 11:51.

  • #2
    Welcome to Statalist!

    You don't tell us what command you are using to run your tabulations, but assuming it is the tabulate command, help tabulate twoway would tell you that the missing option will cause it to treat missing values like other values. Will that be what you need? Here's an example using the built-in auto data.
    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . tab rep78 foreign, missing
    
        Repair |
        Record |       Car type
          1978 |  Domestic    Foreign |     Total
    -----------+----------------------+----------
             1 |         2          0 |         2
             2 |         8          0 |         8
             3 |        27          3 |        30
             4 |         9          9 |        18
             5 |         2          9 |        11
             . |         4          1 |         5
    -----------+----------------------+----------
         Total |        52         22 |        74
    Last edited by William Lisowski; 06 Dec 2015, 11:57.

    Comment


    • #3
      Hi thanks for replying!

      I've been trying all sorts of commands but I though tab would make the most sense. I've just done tabulate twoway yesno ethnicity but it doesn't tell me what group of yes/no the missing values of ethnicity fall into, just the values which are not missing.

      Comment


      • #4
        Had I gotten there before William, I would have given you essentially the same reply he did. So I think neither he nor I understands what you want. Perhaps you can make it clearer by showing us some sample data and then what the result you are looking for would be.

        Comment


        • #5
          I agree with Clyde. We can better help you if we know what commands you have tried and what Stata displayed to you. Based on what you reported, the command I recommended would be
          Code:
          tabulate yesno ethnicity, missing
          rather than, as you reported,
          Code:
          tabulate twoway yesno ethnicity
          since twoway isn't part of the syntax, and the missing option is required to display missing values.

          You perhaps overlooked the Advice on Posting link on the page you used to create your post. Please review that, which is also available as the Statalist FAQ linked to from the top of every page. See especially sections 9-12 on how to best pose your question. It's particularly helpful to copy commands and output from your Stata Results window and paste them into your Statalist post using CODE delimiters, as described in section 12 of the FAQ.

          Finally, let me add that, using Stata terminology, I understand you to say that 203 of the observations in your dataset have a missing value for ethnicity, and the variable yesno takes two distinct values, "yes" and "no". It's important to distinguish between observations (shown as rows in your data), variables (shown as columns in your data), and values (of a particular variable, for particular observations), even if only to reduce the chance of misunderstanding.
          Last edited by William Lisowski; 06 Dec 2015, 13:30.

          Comment


          • #6
            Hi,

            Thank you both for your help, I will review how to phrase my questions better and provide data next time.

            Code:
            tabulate twoway yesno ethnicity Was what I was looking for, thank you William

            Sam

            Comment


            • #7
              Originally posted by Sam Wang View Post
              tabulate twoway yesno ethnicity Was what I was looking for
              Could you please confirm the command that you used?
              Code:
              tabulate twoway yesno ethnicity
              is not a valid Stata command and will return one of the following error messages:
              Code:
              variable twoway not found
              r(111);
              
              too many variables specified
              r(103);
              You get the second error messages if one of the variables in your dataset is called twoway.

              Comment

              Working...
              X