Announcement

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

  • dropping or keeping variables with wildcard

    Ok, so I know that if you type the following Stata will drop all variables that begin with aaa.
    . drop aaa*
    But what if I want to drop all the variables that contain "aaa". I don't mind using "keep" either if it makes this easier.

    Thanks in advance.


  • #2
    It's just *aaa* but check first what you are catching.

    Code:
    clear
    set obs 1
    foreach v in baaa aaab poohbaaah {
       gen `v' = 42
    }
    
    . d *aaa*
    
                  storage   display    value
    variable name   type    format     label      variable label
    -------------------------------------------------------------------------------
    baaa            float   %9.0g                 
    aaab            float   %9.0g                 
    poohbaaah       float   %9.0g                 
    
    . drop *aaa*

    Comment


    • #3
      Aaah so simple, just a star at the beginning and another at the end. Thanks so much Nick.

      Comment

      Working...
      X