Hi all,
First of all, here is my data:
I have several IDs, I chose to show this one for conciseness and because it represents a good example of what I would like to do.
Right now, the dataset is as follows (it is not xtset: there is no time variable):
I would like it to be like this:
So that all the information by ID is in the most recent observation (row). After that, I should enable me to run
with all the data being contained in the last row.
I naively tried running
but got the error "weights not allowed". In addition, I am not even sure that this is the right command to execute to obtain what I want.
Any ideas on how to proceed?
Many thanks!
Maxence Morlet
First of all, here is my data:
Code:
input long id float(gradeCH_SF_HK1 gradeGP_EF_PP gradeGP_EF_ZK1 gradeEN_ZK) 599518 . . 5.5 . 599518 . 5 . . 599518 . . . 5
Right now, the dataset is as follows (it is not xtset: there is no time variable):
id | gradeCH_SF_HK1 | gradeGP_EF_PP | gradeGP_EF_ZK1 | gradeEN_ZK |
599518 | . | . | 5.5 | . |
599518 | . | 5 | . | . |
599518 | . | . | . | 5 |
I would like it to be like this:
id | gradeCH_SF_HK1 | gradeGP_EF_PP | gradeGP_EF_ZK1 | gradeEN_ZK |
599518 | . | . | 5.5 | . |
599518 | . | 5 | . | . |
599518 | . | 5 | 5.5 | 5 |
So that all the information by ID is in the most recent observation (row). After that, I should enable me to run
Code:
keep if _n==_N
I naively tried running
Code:
bysort id: replace grade*[_N]==grade*[_n-1] if grade[_N]==. & grade*[_n-1]!=.
Any ideas on how to proceed?
Many thanks!
Maxence Morlet
Comment