Login or Register
Log in with
Forums
FAQ
Search in titles only
Search in General only
Advanced Search
Search
Home
Forums
Forums for Discussing Stata
General
You are not logged in. You can browse but not post. Login or
Register
by clicking 'Login or Register' at the top-right of this page. For more information on Statalist, see the
FAQ
.
Announcement
Collapse
No announcement yet.
X
Collapse
Posts
Latest Activity
Search
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Filtered by:
Clear All
new posts
Muhammad Ibrahim Shah
Join Date:
Nov 2020
Posts:
49
#1
keeping the last observation only
28 Nov 2021, 01:33
I have different individuals and want to keep the last observation only. any commands?
Joseph Coveney
Join Date:
Apr 2014
Posts:
4352
#2
28 Nov 2021, 02:19
Last observation of each individual? Then try
Code:
bysort pid (tim): keep if _n == _N
where pid is the person's identiffier and tim is a variable that increases with time. Otherwise, if the last observation overall, then try
Code:
sort tim, stable keep in l
Comment
Post
Cancel
Muhammad Ibrahim Shah
Join Date:
Nov 2020
Posts:
49
#3
03 Feb 2022, 13:24
Thanks!
Comment
Post
Cancel
Previous
Next
Working...
Yes
No
OK
OK
Cancel
X
Comment