Announcement

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

  • How to calculate between related variables?




    Own a bike? Brand of bike?

    Person 1 1 1

    Person 2 2 3

    Person 3. 1 2

    Person 4. 2 3

    Person 5 1 2

    Person 6. 2 3




    Own a car

    1 = Yes

    2 = No

    0 = NA




    Brand of bike

    1 = Brand A

    2 = Brand B

    3 = NA




    I want to find out of the people who own bike (so 1’s), how many own Brand A (i.e. the 1s). What should I input on Stata?




  • #2
    Dear Meg Hua, welcome to the forum. Please consult the FAQ before posting. Here you will advice on how to provide data examples before posting question (in short: use the command -dataex-). Sometimes it is possible to answer data-specific-questions that are posed even without dataexamples provided by -dataex-, however, when you don't provide the names of you variables, it is impossible for anyone to provide you with an input which will produce your desired result.
    Last edited by Emil Alnor; 15 Sep 2022, 08:43.

    Comment


    • #3
      Meg:
      Emil gave an excellent advice.
      Therefore, please consider what follows as a temptative reply to your query:
      Code:
      tab Brand_of_bike if Own_a_bike==1
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Originally posted by Carlo Lazzaro View Post
        Meg:
        Emil gave an excellent advice.
        Therefore, please consider what follows as a temptative reply to your query:
        Code:
        tab Brand_of_bike if Own_a_bike==1
        Thank you Emil and Carlo - when I input this command, it comes up with type mismatch r(109) though?

        Comment


        • #5
          Originally posted by Carlo Lazzaro View Post
          Meg:
          Emil gave an excellent advice.
          Therefore, please consider what follows as a temptative reply to your query:
          Code:
          tab Brand_of_bike if Own_a_bike==1
          Thank you Emil and Carlo - when I input this command, it comes up with type mismatch r(109) though?

          Comment


          • #6
            first, note that this is why we ask for example data using -dataex- and posted in CODE blocks - please read the FAQ

            second, use a two way table; e.g.,
            Code:
            ta Brand_of_bike Own_a_bike
            the variable listed first should generally be the variable with more categories (just so it shows up easier on the screen)

            Comment

            Working...
            X