I'm struggling to come up with a solution for finding if each observation in variable 1 matches ANY of the specified observations in v2.I'm trying to narrow the data to focus on passengers that have arrived on-time at least one time in the data. That way I can look at those passengers' data, even for points when they weren't on time.
I'm trying to pass a numlist to anymatch of the names of the ID's of the passengers that have arrived on time at least one time but I'm getting an error.
"values() invalid -- invalid numlist"
This is my code:
g on_time= passengers if timely==1; // limiting to timely arrivals.
levelsof on_time;
g on_time_levels= r(levels); //unique numlist of passengers with timely arrivals (unsure of this)
g on_time_ever=.;
forvalues i =1/6939 {;
egen tempvariable = anymatch(passengers) if _n==`i',values(on_time_levels);
replace on_time_ever=tempvariable if _n==`i';
drop tempvariable;
};
I am unsure if the levels var I generated is really a numlist. How else can I get a numlist from this variable so I can pass it to anymatch? Or am I just going about this completely wrong?
Thanks!
Related Posts with Using anymatch in a forvalue loop to detect if each value in v1 matches ANY value in v2
equality-of-distributions testHow can I perform Kolmogorov-Smirnov-Lilliefors test of normality test? I know that "ksmirnov'" comm…
unreconnized commandHello! Please can anyone help me: I am using STATA 15 to run a Heckprobit, when I ask for mfx I get …
InterpretationI have the below model, how should I interpret B6: There is a decrease in children by 0.21(It does n…
Download STATA 15 SE 64 Bit Full VersionDownload STATA 15 SE 64 Bit Full Version …
Pseudo R2 for mprogit - Loglik with intercept-only modelI run both mlogit and mprobit regressions. Stata reports pseudo R2 for mlogit but not for mprobit. …
Subscribe to:
Post Comments (Atom)
0 Response to Using anymatch in a forvalue loop to detect if each value in v1 matches ANY value in v2
Post a Comment