Announcement

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

  • Dropping variables in the batch structure

    My dataset contains ~4000 variables from a survey that collected data on upto 10 members from the same household. (AGE_01, AGE_02...AGE_10/SEX_01, SEX_02.... SEX_10/BMI_01, BMI_02.....BMI_10).

    Is it possible to keep only the FIRST observation for all the variables (AGE1, SEX1, BMI1) by dropping the rest.

  • #2
    Something in the neighborhood of:
    Code:
    keep *_01 x y z
    where x y z represent any variables you want besides the ones referenced by *_01, should work. See -help varlist- and -help keep-.

    Comment


    • #3
      Originally posted by Mike Lacy View Post
      Something in the neighborhood of:
      Code:
      keep *_01 x y z
      where x y z represent any variables you want besides the ones referenced by *_01, should work. See -help varlist- and -help keep-.
      Thanks very much Mike. keep *_01 did the trick. This method retains all variables containing "_01", which is little troublesome as some of the variables are not numbered and still need to be retained. I didn't foresee this actually. Is there a way to drop solely the variables numbered as:
      _02, _03....

      Comment


      • #4
        try
        Code:
        drop *_02 *_03 *_04 ...

        Comment


        • #5
          Originally posted by Rich Goldstein View Post
          try
          Code:
          drop *_02 *_03 *_04 ...
          It worked. Thanks so much!

          Comment

          Working...
          X