Announcement

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

  • Listing of numeric non-empty cells

    Hi Stata Forum,

    i have the following problem: I have a large dataset and i need to list all variables that are not empty. They are not string variables, so i can not use the list var1 if strpos(var1, "XXX") syntax. An example would be the following: I have var1 with values of 2; 3 and also an empty cell. How can i get a list of all non-empty values (here it would be 2 and 3)?

    Thank you very much for your help!
    Best regards!

  • #2
    I'm not sure I understand what you need.. but

    Code:
    list var1 var2 ... varn if !missing(var1, var2, ..... ,varn)
    lists all the observations for which you have non missing values for all variables

    Comment


    • #3
      If I understood right your query, you may use something like:

      Code:
      sysuse auto
      foreach var of varlist make-foreign {
      list `var' if missing(`var')
      }
      foreach var of varlist make-foreign {
      list `var' if !missing(`var')
      }
      foreach var of varlist price-foreign {
      list `var' if !missing(`var') & `var' == 3 | `var'== 2
      }
      Hopefully that helps.
      Best regards,

      Marcos

      Comment


      • #4
        Alright thank you guys! Both codes are working pretty good for my problem ! Thank you and best regards!

        Comment

        Working...
        X