Hello! I am looking at the results of a survey in which some respondents submitted a response prematurely and then later submitted a full response. I would like to drop the earlier response, but when I drop duplicates by name, it drops the later response instead (e.g. I have two observations from Joe Smith and I want to drop the response from 2 p.m. but Stata drops the response from 5 p.m. of the same day and keeps the 2 p.m. observation).
Since there's not too many, I decided to do it manually but my timestamp is automatically converted to type double, format %tc and so I'm having trouble figuring out how to use it in an if-statment. For example:
drop if (Timestamp == "05sep2019 15:51:41" & Name == "Joe Smith")
drop if (Timestamp == 05sep2019 15:51:41 & Name == "Joe Smith")
Both return a type mismatch and I don't know how to address this. Converting to an int or string lost data. Alternately, if there's a better way to drop duplicates in a "Name" variable by the *earlier* datetime, I'd really appreciate any suggestions on that.
Thank you!
Related Posts with Using datetime in an expression? (Or dropping duplicates with an *earlier* datetime?)
Why is this regression in Stata not progressing nor returning an error code?Note: Originally posted on Stack Overflow, but crossposted here following advice. I am running a m…
History Pane in Command window - how to set the max capacity of thishello stata people, complete newcomer here, I have been using the command history pane of the comman…
Time and region fixed effects (When is it appropriate to use c. and i. for the time trends?)I did come to realize that when controlling for time effects and region effects in a regular regress…
KHB command for mediation analysis Hello. I am using the user-written command "KHB" (Karlson/Holm/Breen) to run a mediation analysis (…
Data display in browser converting from 24 hr clock to 12 hour clockIn the data browser Stata is displaying 12jun2018 16:38:53 as 6/12/2018 4:33 as if it were labeling …
Subscribe to:
Post Comments (Atom)
0 Response to Using datetime in an expression? (Or dropping duplicates with an *earlier* datetime?)
Post a Comment