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.
Related Posts with Help Building a Loop to tell me which observations meet my Criterion
Regular expression in StataDear Stata users, Regular expression is used frequently nowadays. Stata's help file on regular expr…
2sls regression with interaction between endogenous and exogenous variablesI am having an endogenous variable X1 and an exogenous variable X2 and instruments Z1 and Z2 for my …
How to rank firms into decilesHello, I try to measure investment efficiency in this paper "How does financial reporting quality r…
How to create a sequence within a group?Hello, I appreciate your help on this. I have patient level data with and ID and subID. I want to …
Brant test for parallel regression lines dependent on coding of dependent variableI estimate an ordinal logistic regression model and use 'oparallel' to get the p-value from a Brant …
Subscribe to:
Post Comments (Atom)
0 Response to Help Building a Loop to tell me which observations meet my Criterion
Post a Comment