-1

I am trying to get delete observations that occurred outside of my study's time restrictions using Stata.

At the moment i have a variable Start_Finish that define the study time contraints. The first photoNo observations need to be deleted is how I want all of them to look like by the end. How could i delete all the observations that occur between a Finish tag and the ensuing Start tag that need to be excluded? Example of space after a Finish tag that I want to delete

Nick Cox
  • 35,529
  • 6
  • 31
  • 47
  • 3
    This is too difficult to read at present. One has to read the question and at the same time cross-refer to two listings. The use of images means that people cannot copy and paste your sample data easily or write code for you. Please study other Stata questions here or indeed the advice at http://www.statalist.org/forums/help#stata on how to present example data in self-contained postings. – Nick Cox Jan 18 '17 at 23:42
  • If the answer is correct, please mark it as resolved (click the grey check under the downvote arrow) – timat Feb 13 '17 at 18:18

1 Answers1

1

This should work. But it would had been easier to test if you provide data as suggested in the comment.

gen temp = 1 if start_finish == "Start"
replace temp = 0 if start_finish == "Finish"
replace temp = 1 if temp[_n-1]==1 & temp[_n] != 0
drop if missing(temp)
drop temp
timat
  • 1,480
  • 13
  • 17