I have a dataset of the following form
AFG 0011 7
ALB 0011 23
NLD 0011 234
USA 0011 245
AFG 0012 5
ALB 0012 12
NLD 0012 345
USA 0012 334
ALB 0013 34
NLD 0013 56
USA 0013 59
NLD 0015 67
USA 0015 68
I need to transform it into the following conventional matrix
AFG ALB NLD USA
0011 7 23 234 245
0012 5 12 345 334
0013 NA 34 56 59
0015 NA NA 67 68
I'm fine if NAs are sustituted with 0s. Unfortunately, I was not able to find a simple solution, as subvectors (AFG, ALB, NLD, USA or NLD, USA) are of different lengths. Will be very grateful for any help.