[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: combinations of while, if, by, and foreach commands
Using Stata 8.1 SE, I'm trying to put together a loop for what I imagine should be quite a straightforward task.
The relevant part of my data looks like the following:
id cons time
5001574 0.278548 30
5001574 0.271683 29
5001574 0.378903 28
5001574 0.291933 27
5001574 0.319807 26
5001574 0.348804 20
5001574 0.247645 19
5001574 0.306516 18
5001574 0.303717 17
5001574 0.310532 16
I have about 8000 different id values in the full dataset, observed for different stretches of time with different numbers of gaps in the cons variable in different places across the set of ids.
What I would like to do is drop the observations at the end of the time series where cons=., but keep the observations in the middle. There are varying numbers of gaps in the cons time series for different ids, and I want to keep all of them except the observations at the end of the time series for each id. I've tried a number of different combinations of the while, if and foreach commands, but none of them has worked, so I hoped that someone on the list could help.
Any help would be much appreciated.
* For searches and help try: