Hi everyone,
I have input output table data (by countries and sectors for a specific year) in a matrix format that I would like to convert to a stata friendly format. I am sorry I can't share the original data but I will share a hypothetical example.
The data comes in two separate .txt files, one for the labels and one for the data itself. When I import them on Stata they would look like this:
Labels:
Data
This is eventually the matrix format of the data if we combine the data with the labels manually (just to give you an understanding of what it means)
What I want to do is that I would like to convert this matrix to a Stata friendly format like the one below for example. I would be grateful if you could advise.
Many thanks in advance.
Jala
I have input output table data (by countries and sectors for a specific year) in a matrix format that I would like to convert to a stata friendly format. I am sorry I can't share the original data but I will share a hypothetical example.
The data comes in two separate .txt files, one for the labels and one for the data itself. When I import them on Stata they would look like this:
Labels:
v1 | v2 |
Country 1 | Sector 1 |
Country 1 | Sector 2 |
Country 2 | Sector 1 |
Country 2 | Sector 2 |
Data
v1 | v2 | v3 | v4 |
346 | 156 | 819 | 154 |
354 | 443 | 42 | 92 |
547 | 466 | 518 | 149 |
752 | 936 | 611 | 496 |
This is eventually the matrix format of the data if we combine the data with the labels manually (just to give you an understanding of what it means)
Country 1 | Country 1 | Country 2 | Country 2 | ||
Sector 1 | Sector 2 | Sector 1 | Sector 2 | ||
Country 1 | Sector 1 | 346 | 156 | 819 | 154 |
Country 1 | Sector 2 | 354 | 443 | 42 | 92 |
Country 2 | Sector 1 | 547 | 466 | 518 | 149 |
Country 2 | Sector 2 | 752 | 936 | 611 | 496 |
What I want to do is that I would like to convert this matrix to a Stata friendly format like the one below for example. I would be grateful if you could advise.
country origin | sector origin | country destination | sector destination | value |
Country 1 | Sector 1 | Country 1 | Sector 1 | 346 |
Country 1 | Sector 1 | Country 1 | Sector 2 | 156 |
Country 1 | Sector 1 | Country 2 | Sector 1 | 819 |
Country 1 | Sector 1 | Country 2 | Sector 2 | 154 |
Country 1 | Sector 2 | Country 1 | Sector 1 | 354 |
Country 1 | Sector 2 | Country 1 | Sector 2 | 443 |
Country 1 | Sector 2 | Country 2 | Sector 1 | 42 |
Country 1 | Sector 2 | Country 2 | Sector 2 | 92 |
Country 2 | Sector 1 | Country 1 | Sector 1 | 547 |
Country 2 | Sector 1 | Country 1 | Sector 2 | 466 |
Country 2 | Sector 1 | Country 2 | Sector 1 | 518 |
Country 2 | Sector 1 | Country 2 | Sector 2 | 149 |
Country 2 | Sector 2 | Country 1 | Sector 1 | 752 |
Country 2 | Sector 2 | Country 1 | Sector 2 | 936 |
Country 2 | Sector 2 | Country 2 | Sector 1 | 611 |
Country 2 | Sector 2 | Country 2 | Sector 2 | 496 |
Jala
Comment