Announcement

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

  • Dummy variable missing data

    I have a large dataset of countries over a 20 year period
    I am trying to create a dummy variable for developing countries
    Countries with a GDP per capita lower then $10,000 are considered developing
    some countries have missing data for certain years
    when I create my dummy variable it codes missing observations as 0 for the dummy
    How do I get it to code the missing data in GDP per capita as missing data in my dummy variable?



  • #2
    Code:
    gen wanted = (gdp_per_capita > 10000) if !missing(gdp_per_capita)
    In the future, when asking for help with code, please use the -dataex- command and show example data. Although sometimes, as here, it is possible to give an answer that has a reasonable probability of being correct, this is usually not the case. Moreover, such answers are necessarily based on experience-based guesses or intuitions about the nature of your data. When those guesses are wrong, both you and the person trying to help you have wasted their time as you end up with useless code. To avoid this, a -dataex- based example provides all of the information needed to develop and test a solution.

    If you are running version 18, 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.

    Comment


    • #3
      Thank you very much Clyde.

      You solution worked perfectly.

      In the future I will include my example data, apologies for the admission, I was not aware of this option.

      Comment

      Working...
      X