I am currently working with a dataset that has information on individuals i = 1,...,N by time t = 1,...,T. I basically have a panel structure in my dataset. However, I want to select only one row of data from each individual. Specifically, I want to select only the last time period t=T for each individual i=1,...,N. How can I 'extract' this specific information from the bigger dataset?
In Stata [not STATA] rows are more properly called observations. You can "select" the last observation in each panel with the generic
bysort id (time) : ... if _n == _N
as under the aegis of
the built-in variable
_n identifies observations in each panel
_N is the number of observations in each panel and therefore identifies the last observation in each panel.
This is well documented: e.g. see the help and manual entries explaining the