Announcement

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

  • drop missing observations

    Hi I am actually trying to clean out my panel dataset. Basically I have variables such as name, year, cash, sic code, total assets, current assets etc. In my dataset, there are companies with name, year and sic but without accounting data such as cash, current assets for certain years. Can anyone tell me how to remove observations in my dataset if i wish to drop observations when total assets, cash, current assets are missing. Thank you so much.

  • #2
    Some variation on

    Code:
    drop if missing(total, cash, current) 
    where naturally you need to use the variable names which you haven't told us.

    Comment


    • #3
      Hi Wang

      I think you need to investigate further the missing data, and find out why they are missing. Dropping observations may not necessary solve the problem especially if you have a small sample size and the missing values are more than 10%. You might want to try multiple imputation method as It may be a better approach that lit-wise deletion.

      Otherwise, if you wish to drop the observation
      then the code:
      drop if cash = . will very likely do the job

      Comment


      • #4
        Chinonso: Typo there. You mean

        Code:
        drop if cash == .

        Comment


        • #5
          Hi Nick

          Many thanks for the correction. Yes, that,s what I mean. I have been trying to get my head around how to use this format to type codes but have I not be able to that.

          May be you can point me to the right direction.

          Cheers

          Comment


          • #6
            Hi Chinonso Thank you so much for your advice. The reason I decided to drop certain observation is due to data unavailibility.

            Thank you Nick!

            Comment


            • #7
              Sorry, I am just trying to see if this works

              [code:
              drop if cash==.][/CODE]

              Comment


              • #8
                Let me note that often you don't need to take the trouble to drop observations with missing data - most Stata estimators automatically drop observations where data is missing on any of the included variables. As Chinonso notes, missing data can create issues of bias in estimates but this may be a bit more advanced than Yu is ready for right now.

                That said, there are occasions where dropping observations makes sense - for example so you don't do calculations of differing sets of observations where different variables have different missing observations.

                Comment


                • #9
                  I think what you should be doing is
                  drop if (total ==.| cash ==.| current ==.)
                  Last edited by Caliph omar; 01 Aug 2018, 13:42.

                  Comment


                  • #10
                    Loosely #9 is the same solution as #2. (Loosely, because in principle missing values include .a .... .z.

                    Comment

                    Working...
                    X