Dear Statalist,
Can someone help me to figure out how to drop observations from the
data based on following criteria.
Data sample.
clear
input byte id byte value str6 frequency
1 25 MON
1 22 SUN
1 30 WED
1 28 SAT
2 24 TUE
2 35 SAT
2 50 SUN
2 26 FRI
3 30 MON
3 28 SUN
3 35 SAT
4 50 MON
4 38 WED
4 30 SUN
5 25 MON
5 23 TUE
5 24 SUN
end
list
For each ID variable I have values for different days in a week. I
want to keep only the values associated with Sunday, Saturday and
Monday. If Monday is not available I like to keep the weekday that is
closer to monday in the order mon, tue, wed, thu, fri. Saturday and
Sunday are not available for all IDs. Similarly the number of
frequencies (SUN, MON, TUE etc..) associated with the IDs might be
different for each IDs. Can someone help me figure out how to drop
these observations. Eventually I want to retain only a maximum of
three observations with each IDs. One weekday, SUN, and SAT (if
available)
Thanks in advance,
Rijo.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/