Announcement

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

  • egen nonmissing

    Hey,
    I want to create a varibale which counts a number of countries.
    egen Number_of_countries= rownonmiss (country1 country2 country3 country4 country5)
    or egen Number_of_countries= count (country1 country2 country3 country4 country5)
    The Variable Number_of_countries should Show the number of countries with nonmissingvalues or names, so a Maximum of 5

  • #2
    what is the question? it appears that the code you show (if you deleted the space after "rownonmiss") should be exactly what you want

    Comment


    • #3
      Sorry for being unprecise
      type mismatch
      r(109);
      The countries are all strings.
      So the question is: What is wrong?
      Or better, what do I have to Change you make it work


      Comment


      • #4
        if you look at the help file, you MUST use the "strok" option

        Comment


        • #5
          The documentation for egen says

          String variables may not be specified unless the strok option is also specified. If strok is specified, string variables will be counted as containing missing values when they contain "". Numeric variables will be counted as containing missing when their value is ">.".
          So all you need is adding the strok option.

          Do not get me wrong, but typing

          Code:
          help egen
          is really the minimum that you are expected to do before posting on the list.

          Best
          Daniel

          Comment


          • #6
            Thanks,
            I must have overlooked the strok Option!
            Sorry for that!
            Thanks again!

            Comment

            Working...
            X