Announcement

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

  • Saving part of a dataset

    Hi, I have 33 variables and 1000 participants. The 33rd variable has 20 participants with data entered. The 980 other participants have missing data. All other variables have basically complete data.
    I want to save a new dataset containing just the 20 participants with data for the 33rd variable. I want the new dataset to include all 33 variables for those 20 participants.
    Is there a way to do this?

    Thanks

  • #2
    save does not support if so you need

    Code:
    keep if !missing(var33) 
    save mydata
    although savesome (SSC) is a wrapper for the same kind of two-step operation,

    Comment


    • #3
      Guest:
      first of all, I would save a copy of the original dataset.
      Then, I would try:
      Code:
      drop if 33_rd==.
      PS: crossed in the cyberspace with Nick's helpful advice, that deals with the same matter from the opposite end of the wire (-keep- vs -drop-).
      Last edited by sladmin; 18 Jul 2025, 11:55. Reason: anonymize original poster
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment

      Working...
      X