I have a table A like this:
cou | own | ind | aus_d_a | usa_f_b |
---|---|---|---|---|
AUS | D | A | 3268.02 | 85.087 |
AUS | D | B | 92.1329 | 10808.3 |
and I want to reshape it to long type data as follows, table B:
cou | own | ind | cou2 | own2 | ind2 | value |
---|---|---|---|---|---|---|
AUS | D | A | aus | d | a | 3268.02 |
AUS | D | B | aus | d | a | 92.1329 |
AUS | D | A | usa | f | b | 85.087 |
AUS | D | B | usa | f | b | 10808.3 |
but I don't know how to code it using R or Stata? anyone can help me, thanks a lot
PS: the data is just a sample, actually I have thousands of columns (three dimensions: country_ownership_industry, eg aus_d_c21), 60 countries, 2 ownership, 34 industries, so I have 4080 cols.