Announcement

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

  • Calculating the amount of observations in a column

    Hello all,

    I have a column of data (to which I have attached a photo below), where certain rows of data are missing. I would like to calculate the amount of observations in the column "straddle_3d" (in other words the amount of rows with data). Those anyone know how this could be done?

    Thanks

    Click image for larger version

Name:	Column Stata.png
Views:	1
Size:	5.7 KB
ID:	1663552

  • #2
    Code:
    count if !missing(straddle_3d)
    will display it in the results window. And if you need to save that value for later use, it is left behind in r(N).

    If you want to create a variable containing it, -egen, count()- will do that. But I don't recommend making a variable for this since it is really a constant, so should be stored as a scalar or local macro.

    In the future, when showing data examples, please use the -dataex- command to do so. 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.

    Comment


    • #3
      Thank you Clyde

      Comment

      Working...
      X