montaguelord
New Member
- Joined
- Dec 4, 2008
- Messages
- 5
I have an Excel 2016 file with a large set of panel data in the following actual form:
[TABLE="width: 261"]
<tbody>[TR]
[TD]VAR[/TD]
[TD]ISO[/TD]
[TD="colspan: 3, align: center"]VALUE[/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]1990[/TD]
[TD="align: center"]1991[/TD]
[TD="align: center"]1992[/TD]
[/TR]
[TR]
[TD]IMPORTS[/TD]
[TD] ARG[/TD]
[TD] 1,287 [/TD]
[TD] NA [/TD]
[TD] NA [/TD]
[/TR]
[TR]
[TD]IMPORTS[/TD]
[TD] AUS[/TD]
[TD] 9,178 [/TD]
[TD] 447 [/TD]
[TD] 10,792 [/TD]
[/TR]
[TR]
[TD]IMPORTS [/TD]
[TD] AUT[/TD]
[TD] NA [/TD]
[TD] NA [/TD]
[TD] 1,325 [/TD]
[/TR]
[TR]
[TD]GDP [/TD]
[TD] ARG[/TD]
[TD] 153 [/TD]
[TD] 206 [/TD]
[TD] 248 [/TD]
[/TR]
[TR]
[TD]GDP [/TD]
[TD] AUS[/TD]
[TD] 323 [/TD]
[TD] 324 [/TD]
[TD] 317 [/TD]
[/TR]
[TR]
[TD]GDP [/TD]
[TD] AUT[/TD]
[TD] 167 [/TD]
[TD] 174 [/TD]
[TD] 196 [/TD]
[/TR]
</tbody>[/TABLE]
I need to transform it to the following desired form:
[TABLE="width: 171"]
<tbody>[TR]
[TD]ISO[/TD]
[TD]YEAR[/TD]
[TD="colspan: 2"]VAR[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"][/TD]
[TD="align: right"]IMPORTS[/TD]
[TD="align: right"]GDP[/TD]
[/TR]
[TR]
[TD="align: right"]ARG[/TD]
[TD="align: right"]1990[/TD]
[TD="align: right"]1,287 [/TD]
[TD="align: right"]153 [/TD]
[/TR]
[TR]
[TD="align: right"]ARG [/TD]
[TD="align: right"]1991[/TD]
[TD="align: right"] NA [/TD]
[TD="align: right"]206 [/TD]
[/TR]
[TR]
[TD="align: right"]ARG[/TD]
[TD="align: right"]1992[/TD]
[TD="align: right"] NA [/TD]
[TD="align: right"]248 [/TD]
[/TR]
[TR]
[TD="align: right"]AUS[/TD]
[TD="align: right"]1990[/TD]
[TD="align: right"]9,178 [/TD]
[TD="align: right"]323 [/TD]
[/TR]
[TR]
[TD="align: right"]AUS[/TD]
[TD="align: right"]1991[/TD]
[TD="align: right"] 447 [/TD]
[TD="align: right"]324 [/TD]
[/TR]
[TR]
[TD="align: right"]AUS[/TD]
[TD="align: right"]1992[/TD]
[TD="align: right"]10,792 [/TD]
[TD="align: right"]317 [/TD]
[/TR]
[TR]
[TD="align: right"]AUT[/TD]
[TD="align: right"]1990[/TD]
[TD="align: right"] NA [/TD]
[TD="align: right"]167 [/TD]
[/TR]
[TR]
[TD="align: right"]AUT[/TD]
[TD="align: right"]1991[/TD]
[TD="align: right"] NA [/TD]
[TD="align: right"]174 [/TD]
[/TR]
[TR]
[TD="align: right"]AUT[/TD]
[TD="align: right"]1992[/TD]
[TD="align: right"]1,325 [/TD]
[TD="align: right"]196 [/TD]
[/TR]
</tbody>[/TABLE]
Can anyone suggest a way to automatically transform the data from the actual format to the desired form:
I thought that a pivot table might work. But I don’t know how to do a multi-level pivot table that would have the ISO and YEAR in the same line.
Any suggestions would be grately appreciated!
[TABLE="width: 261"]
<tbody>[TR]
[TD]VAR[/TD]
[TD]ISO[/TD]
[TD="colspan: 3, align: center"]VALUE[/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]1990[/TD]
[TD="align: center"]1991[/TD]
[TD="align: center"]1992[/TD]
[/TR]
[TR]
[TD]IMPORTS[/TD]
[TD] ARG[/TD]
[TD] 1,287 [/TD]
[TD] NA [/TD]
[TD] NA [/TD]
[/TR]
[TR]
[TD]IMPORTS[/TD]
[TD] AUS[/TD]
[TD] 9,178 [/TD]
[TD] 447 [/TD]
[TD] 10,792 [/TD]
[/TR]
[TR]
[TD]IMPORTS [/TD]
[TD] AUT[/TD]
[TD] NA [/TD]
[TD] NA [/TD]
[TD] 1,325 [/TD]
[/TR]
[TR]
[TD]GDP [/TD]
[TD] ARG[/TD]
[TD] 153 [/TD]
[TD] 206 [/TD]
[TD] 248 [/TD]
[/TR]
[TR]
[TD]GDP [/TD]
[TD] AUS[/TD]
[TD] 323 [/TD]
[TD] 324 [/TD]
[TD] 317 [/TD]
[/TR]
[TR]
[TD]GDP [/TD]
[TD] AUT[/TD]
[TD] 167 [/TD]
[TD] 174 [/TD]
[TD] 196 [/TD]
[/TR]
</tbody>[/TABLE]
I need to transform it to the following desired form:
[TABLE="width: 171"]
<tbody>[TR]
[TD]ISO[/TD]
[TD]YEAR[/TD]
[TD="colspan: 2"]VAR[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"][/TD]
[TD="align: right"]IMPORTS[/TD]
[TD="align: right"]GDP[/TD]
[/TR]
[TR]
[TD="align: right"]ARG[/TD]
[TD="align: right"]1990[/TD]
[TD="align: right"]1,287 [/TD]
[TD="align: right"]153 [/TD]
[/TR]
[TR]
[TD="align: right"]ARG [/TD]
[TD="align: right"]1991[/TD]
[TD="align: right"] NA [/TD]
[TD="align: right"]206 [/TD]
[/TR]
[TR]
[TD="align: right"]ARG[/TD]
[TD="align: right"]1992[/TD]
[TD="align: right"] NA [/TD]
[TD="align: right"]248 [/TD]
[/TR]
[TR]
[TD="align: right"]AUS[/TD]
[TD="align: right"]1990[/TD]
[TD="align: right"]9,178 [/TD]
[TD="align: right"]323 [/TD]
[/TR]
[TR]
[TD="align: right"]AUS[/TD]
[TD="align: right"]1991[/TD]
[TD="align: right"] 447 [/TD]
[TD="align: right"]324 [/TD]
[/TR]
[TR]
[TD="align: right"]AUS[/TD]
[TD="align: right"]1992[/TD]
[TD="align: right"]10,792 [/TD]
[TD="align: right"]317 [/TD]
[/TR]
[TR]
[TD="align: right"]AUT[/TD]
[TD="align: right"]1990[/TD]
[TD="align: right"] NA [/TD]
[TD="align: right"]167 [/TD]
[/TR]
[TR]
[TD="align: right"]AUT[/TD]
[TD="align: right"]1991[/TD]
[TD="align: right"] NA [/TD]
[TD="align: right"]174 [/TD]
[/TR]
[TR]
[TD="align: right"]AUT[/TD]
[TD="align: right"]1992[/TD]
[TD="align: right"]1,325 [/TD]
[TD="align: right"]196 [/TD]
[/TR]
</tbody>[/TABLE]
Can anyone suggest a way to automatically transform the data from the actual format to the desired form:
I thought that a pivot table might work. But I don’t know how to do a multi-level pivot table that would have the ISO and YEAR in the same line.
Any suggestions would be grately appreciated!