Dear all,
I have a dataset that has multiple visits for each person. However each person had a differing number of visits
The dataset is demonstrated below
id visit value
1 1 70
1 2 70
1 3 68
1 4 58
2 1 55
2 2 35
3 1 57
4 1 67
4 2 55
5 1 59
5 2 52
5 3 32
I had a few queries to working on this dataset
1. Is there a command that would allow me to identify:
a) the visit with the lowest value for each id (i.e visit 1 for
b) the value corresponding to the last visit (i.e visit 4 for id 1, visit 3 for id 5) for each id
c) the change and direction of change between the highest and lowest value for each id (i.e for visit 5, the change would be negative 27 over 3 visits)
2. After establishing the above,
Is there a command that would
a) allow me to drop the other visits apart from the desired visit in question - be it the visit with the lowest value, last visit,
b) such that the dataset becomes one visit per id?
I would be grateful for your help with these queries.
Thank you very much
Related Posts with How to sort data for distinct IDs with multiple visits and multiple values
Problem with rename in a loopHello I am trying to rename some variables within a loop, but it returns me error. I have some varia…
Randomly generating new list of room mates and room numbers from an existing listHello, I have a data set with 3 columns that has pairs of roommates with their current room number.…
optimize_init_technique(S, "nr")Hi, I have a methodological question about how optimize works with the Newton-Raphson algorithm. A…
Ali UbaidI am trying Heckman two-step analysis for remittances and agriculture investment based on survey dat…
ERM model for Endogenous treatment effect with nointeract optionI am trying estimate treatment effect models using ERM command in Stata 15. However, it has been sho…
Subscribe to:
Post Comments (Atom)
0 Response to How to sort data for distinct IDs with multiple visits and multiple values
Post a Comment