Hello I need help learning how to drop a variable if one or more observations are greater than a number x. I tried googling this but what i found didn't help or was for one specific variable or if all variables were to be looked at. I only want to look at 100 of the 150 variables I have in my dataset.
Ex. I have variables dist_stop1, dist_stop2 and so on till 100. I want to be able to write a loop that will drop variable "dist_stopP" (with P being a number 1-100) if that variable has an observation bigger than say 33.315.
So if dist_stop4 has observations smaller than 30 and has one observation that is 40.56 then the loop will drop dist_stop4 then move on to dist-stop5.
All of the dist_stop variables are float types.
I have been googling and reading for an hour but nothing is helping. Please help me. Thank you for reading and helping.
0 Response to Dropping Variables Based on Condition and in a Loop
Post a Comment