Hello wonderful people of statlist. I have a question that is based off of an offshoot of a prior question https://www.statalist.org/forums/for...-and-in-a-loop. It is the last comment I wrote there and I have basically copied here to explain a bit better and get more people to look at it.

So my data let us just say for simplicity has a bunch of observations that represent house lots, a variable lot_id to identify those house lots, and many variables dist_stop1 to dist_stop91 which represent the distance from the house lot to those stops. I started on a loop to try and isolate the observations but I don't know of a way to list out which observations meet my distance criterion for each iteration.

I want to also see which observations are say within 1000 units of each stop represented by the many dist_stopx variables. I was thinking of making a loop that would past which observations are kept. The observations are represented by a variable called lot_id. I have set up a loop but I can't get it right. Could you help, I based it off of what you were so kindly provided earlier.

forval x = 1/91{
drop if dist_stop'x' > 1000
}

My line drops all observations that have a value greater than 1000 for the variable at each iteration. My question would be how do I correctly do this as I feel that dropping would affect every subsequent iteration and I don't know how to get stata to display the observations that match my critereon each iteration.

What I am hoping to see is that for variable x, blah blah remained. So it looks like

dist_stop1
1232, 14321, 534123, 8493, 8445

dist_stop2
8949, 6456, ,8941, 3849,

and so on. The numbers after the dist_stopx would be the value of lot_id for that observation.

Do you know how to help me do that or get stata to past that but it doesn't have to be as clean as I exampled above? I just need variable name and lot_id values next to each other.