Announcement

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

  • Reducing data set

    Is there a way to exclude cases from a dataset if they do not have sufficient observations?

    I wrote:

    keep house if _n(VCF0900c >= 45)

    but it didn't work Is there a solution to this problem? Thanks for any help.

  • #2
    I think you've been offered this specific advice recently, but see -help keep- and -help drop-. They have two, mutually exclusive syntactical forms, as is clearly explained.

    Code:
    keep if ....  // filter records and note no varlist
    keep varlist // keep only specified variables in varlist, note no if condition
    Second your syntax is invalid, so this looks like maybe some AI hallucination.

    Code:
    _n(...)
    is not valid. If you want to keep groups defined by variable VCF0900c, which have at least 45 records, here is one possible solution.

    Code:
    bysort _VCF0900c : keep if _N>=45

    Comment

    Working...
    X