Announcement

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

  • No Observation Error with correlation

    Hi everyone,
    I'm very new to Stata and I am very confused my this error. I have created two variables to describe flights from differents airports in Miami to different airports in Dallas. Then, I mean to find a correlation between the prices of plane tickets to the same city, but different airports. The sum function works and I believe I have no missing values, so I have no idea what may be causing the error. I will paste in my code for reference

    pwcorr MiamitoDallasPrice1 MiamitoDallasPrice2
    no observations
    r(2000);

  • #2
    Well, you don't show any example data, so it's hard to be certain what's going on. But there really are only two possible explanations:

    1. One or both of these variables is stored as a string instead of as a numeric variable.
    2. It may happen to be the case that whenever MiamitoDallasPrice1 is non-missing, MiamitoDallasPrice2 is missing, and vice versa.

    In the first situation, you can probably fix the problem using the -destring- command. The second problem, unless it is the result of an error in the data management that created your data set, means that there simply isn't data to support this kind of analysis.

    If you need more specific advice, please include example data when you post back. And be sure to use the -dataex- command to do that. If you are running version 17, 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.

    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment

    Working...
    X