I'd like to list the first 5 observations in a dataset that match a specific condition. For example, in the auto dataset I want to see the first 5 makes that are "foreign." I would like to preserve the order of the dataset and not use a preserve/restore statement. (My real world dataset is very large so sorting, dropping many observations or listing out all observations instead of just a few examples would be cumbersome.)
I've tried:
But this gives me all cars that are foreign in the first 5 observations (not the first 5 observations that have a foreign car).
Thanks and please let me know if I can clarify.
Also, apologies that my username is not my real name -- I made this account many years ago and am not sure how to update it.
I've tried:
Code:
list in 1/5 if foreign==1
Thanks and please let me know if I can clarify.
Also, apologies that my username is not my real name -- I made this account many years ago and am not sure how to update it.
Comment