Say I have the following dataset:
ID ASSET ORIGIN
1 100 1
1 100 8
1 200 1
1 200 8
1 302 2
2 100 1
2 100 8
2 200 1
2 200 8
2 302 2
where ASSET= 100 is Equity, 200 is Fixed Incomes,
and ORIGIN= 1 is domestic, 2 is foreign and 8 is global
I want to create a portfolio snapshot for each ID (variable values= 1 or 0) so that the final dataset looks as below:
ID EQUITY DOMEQUITY FOREQUITY GLOEQUITY FIXED DOMFIXED FORFIXED GLOFIXED
1 1 1 0 1 1 1 0 1
2 1 1 0 1 1 1 0 0
Though I have shown an identical portfolio for the two IDs, it is generally different for different individuals. I have about 23 asset classes and over 72,000 observations. Another thing is that the IDs are not continuous numbers. So I have IDs that go 1,2,6,14 etc.
Any suggestions? I have been struggling with this.