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?)
Marginsplot for logistic regression?Hi guys Variables explained: splitvoter: 0= not split vote between two elections / 1= split vote b…
Cluster SE and Fixed Effects using mlogitDear Statalists, I do not have stata17 so I cannot use xtmlogit. The femlogit does not allow cluste…
How to label variables taking last part of variable namesI have numerous variables. For example, I have variables var1, var3, var6, var30. And I want to labe…
How can i add a variable collected in different time (by region) in cross-sectional model?I'm using a cross sectional data in 2015, and have a poverty rate variable collected in different ye…
How to only keep obvs whose "industry_vertical" value matches a long list of industry verticalsI have a list of firms, firms values, and a variable "industry_verticals" which contains thousands o…
Subscribe to:
Post Comments (Atom)
0 Response to Using datetime in an expression? (Or dropping duplicates with an *earlier* datetime?)
Post a Comment