Announcement

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

  • Equivalent of COUNTBLANK function in Excel

    Hi everyone

    I would like to count the number of blank cells in multiple columns

    The age columns go from 1yr 2yrs 3yrs 4 yrs etc
    I want to know how many times the surveyor chose each of these columns, and which of the columns (i.e. ages) he/she missed.

  • #2
    What does "blank" mean in Stata terms? There are people here fluent in both Stata and Excel (definitely not me) but they still need an explanation. Do you mean missing?

    By columns, do you mean variables or categories of a variable that might be columns in a table?

    This may help.

    https://www.statalist.org/forums/for...aging-missings

    Otherwise if this is not clear, please give us a data example, as we request (FAQ Advice #12).

    Comment


    • #3
      Since you appear new to Stata, let me offer a few hints. First, you'll increase your chances of a useful answer by following the FAQ on asking questions as Nick said. This means provide Stata code in code delimiters, readable Stata output, and sample data using dataex.

      It is unclear exactly what you want to count how. Stata deals in variables and observations, not columns and lines. I should also note that it is usually better to have Stata data in long format rather than wide (e.g., have observations set as

      person1 yr1
      person1 yr2
      person1 yr3
      person2 yr1
      person2 yr2
      etc.

      Blank normally means missing in Excel. If what you want is the number of missing in a given variable then you could do:

      gen a=missing(year1)
      egen b=total(a)

      (there are more efficient ways to do this, but this is simple)



      Comment


      • #4
        I understood you wish to estimate missings in a given set of variables, i.e., row-wise. Being this so, the command - egen - has several options (please type - . help egen -) and some of them will probably suit you.
        Best regards,

        Marcos

        Comment


        • #5
          count if missing(year1)

          is also simple.

          Comment

          Working...
          X