Announcement

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

  • Count observations

    Hello, I am trying to count observations which have the same value for some variable but different ID.
    For example,
    Airline Origin Destination
    AA ORD LAX
    UA ORD LAX
    AA IAD LAX
    UA IAD LAX
    I am trying to figure out the multimarket contact of two airlines(AA and UA). I want count the route where both AA and UA operate nonstop flight.
    So in the example data, AA and UA operate in the 2 markets.
    Please help me to figure out the command for this work. Thank you for your time and attention.




  • #2
    Code:
    by Origin Destination, sort: gen byte contact = (_N == 2)
    In the future, when showing data examples, please use the -dataex- command to do so. If you are running version 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    Comment


    • #3
      This was very helpful information for me as well.

      I have Stata/SE 14.1. When I tried to install dataex using -ssc install dataex- command, Stata gives the following error:


      server refused to send file
      http://fmwww.bc.edu/repec/bocode/d/ either
      1) is not a valid URL, or
      2) could not be contacted, or
      3) is not a Stata download site (has no stata.toc file).

      current site is still http://fmwww.bc.edu/repec/bocode/g/
      r(672);



      Can you please guide if its a version issue or something else?

      Regards

      Moaiz

      Comment


      • #4
        Moaiz.
        what if you type
        Code:
        net install dataex.pkg
        Kind regards,
        Carlo
        (Stata 18.0 SE)

        Comment

        Working...
        X