Dear Statlist,

I am currently trying to organise data from the LISS dataset. A number of variables including within this dataset are not of use to me and I am looking to drop these. The variable each end in a numeric value from 1 to 500 and I am looking to drop a number of these all at once. I was hoping to achieve this by telling stata to drop variables ending in (for example) *100 to *200.

I have been trying to do this with a loop function and varlist but have not had any luck. Please find dataex example below, I have only including 4 variable but in effect would be looking to drop variable cw15h498 to cw15h500 without manually repeating the drop *498 *499 *500 an so on. Thank you for your help.

Kind Regards,

Hugo

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input double(cw15h497 cw15h498 cw15h499 cw15h500)
4 3 4 4
3 3 3 3
end
label values cw15h497 cw15h497
label def cw15h497 3 "3", modify
label def cw15h497 4 "4", modify
label values cw15h498 cw15h498
label def cw15h498 3 "3", modify
label values cw15h499 cw15h499
label def cw15h499 3 "3", modify
label def cw15h499 4 "4", modify
label values cw15h500 cw15h500
label def cw15h500 3 "3", modify
label def cw15h500 4 "4", modify