I have a table with some variables, say var1
and var2
and an identifier, and for some reasons, some identifiers have 2 observations.
I would like to know if there is a simple way to put back the second observation of the same identifier into the first one, that is
- instead of having two observations, each with
var1
var2
variables for the same identifier value
ID var1 var2 ------------------ A1 12 13 A1 43 53
- having just one, but with something like
var1
var2
var1_2
var2_2
.
ID var1 var2 var1_2 var2_2 -------------------------------------- A1 12 13 43 53
I can probably do that with renaming all my variables, then merging the table with the renamed one and dropping duplicates, but I assume there must be a simpler version.