Hi All,
I am working on a dataset that is originally in the matrix format downloaded as an excel spreadsheet from the official website. However, I want to reshape the dataset (as per my understanding) in a long format, where columns and rows are rearranged in just 3 columns namely i (suppliers), j (users), and value. I looked at dataex to provide an example of the data that I have, but I couldn't figure out how to create an example. Therefore, I am providing an example below:
I want to transform the table as follows:
I am trying to get a solution to this issue for a long time. I will be grateful if someone can guide me through this process. I have read on matrix and reshape command. However, reshape only works when column names have a common prefix. Any suggestions on this issue is greatly appreciated. Thanks!
Preety
I am working on a dataset that is originally in the matrix format downloaded as an excel spreadsheet from the official website. However, I want to reshape the dataset (as per my understanding) in a long format, where columns and rows are rearranged in just 3 columns namely i (suppliers), j (users), and value. I looked at dataex to provide an example of the data that I have, but I couldn't figure out how to create an example. Therefore, I am providing an example below:
Agriculture | Manufacturing | ||
Codes i/j | 111 | 1234 | |
111 | Agriculture | 0.40 | 0.30 |
1234 | Manufacturing | 0.30 | 0.50 |
5110 | Services | 0.20 | 0.10 |
9100 | Government | 0.10 | 0.10 |
i (suppliers) | Codes i | j (users) | Codes j | Value |
Agriculture | 111 | Agriculture | 111 | 0.40 |
Manufacturing | 1234 | Agriculture | 111 | 0.30 |
Services | 5110 | Agriculture | 111 | 0.20 |
Government | 9100 | Agriculture | 111 | 0.10 |
Agriculture | 111 | Manufacturing | 1234 | 0.30 |
Manufacturing | 1234 | Manufacturing | 1234 | 0.50 |
Services | 5110 | Manufacturing | 1234 | 0.10 |
Government | 9100 | Manufacturing | 1234 | 0.10 |
Preety
Comment