Announcement

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

  • count missing variables in a row

    Dear all,
    I have a data set in which a variable need to be combined to create a row total (score). I want to generate a variable that count how manay 1s, 2s and missings are there v1 - v6. Below is an example with last three columns need to be generated.
    v1 v2 v3 v4 v5 v6 total 1 total 2 total mis
    1 2 1 . 1 . 3 1 2
    is there any way to do so.
    Many thanks.
    Last edited by Mukesh Kumar; 09 Mar 2017, 09:45.

  • #2
    Mukesh:
    welcome to the list.
    See -help egen-, -rowmiss- function.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Also the egen function anycount()

      Comment


      • #4
        Thank you Carlo. I tried 'rowmiss' (and should have stated as well) but it is just providing missing. I need another variable that tells me that how many variables contain value 1, 2, and so on. I tried 'anyvalue' , but it gives error message that 'too many variables specified.

        Comment


        • #5
          Mukesh:
          Nick' s reply at #3 will give you what you still miss.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            many thanks Carlo and Nick. it works...

            Comment

            Working...
            X