Hello Statalisters,

I am facing the following problem.
This is what my data looks like:

Code:
input str16 Energy_Source str17(B C D)
"Energy Source"            "Industry_Steel"     "Industry_Steel"     "Industry_Steel"    
"Technology"          "Sintering"           "Coking plant"          "Blast furnace"         
"Electricity"            ".0361" ".0333" ".1666"
"Heating oil" "0"                 "0"                 "0"                
"Hard coal"       ".0995" "0"                 ".6466"
And I got this data not only for Steel but for many more industries, various technologies and energy sources.

The data structure I like to get is this:

Code:
"Energy_Source"  "Industry"  "Technology"   
" "                "Steel"       "Sintering"             " .0361"    
"Electricity"             "Steel"       "Coking plant"    ".0333"
"Electricity" "          "Steel"      "Blast furnace"    ".1666"                              
"Heating oil"           "Steel"        "Sintering"          "0"            
"Heating oil"          "Steel"        "Coking plant"    "0"   
"Heating oil"          "Steel"        "Blast furnace"    "0"   
"Hard coal"            "Steel"        "Sintering"          ".0995"
"Hard coal"            "Steel"        "Coking plant"     "0"  
"Hard coal"           "Steel"        "Blast furnace"    ".6466"
From my view, this requires two reshape commands, one for the industry and another for the technology.
However, I get an error message when I try to reshape Industry from wide to long.

Code:
foreach var of varlist B-AA {
replace `var' = "Industry_" + `var' in 1
}
foreach var of varlist B-AA {
   rename `var' `=`var'[1]'
}
reshape long Industry_, i(Energy_Source) j(Industry)


no xij variables found
    You typed something like reshape wide a b, i(i) j(j).
    reshape looked for existing variables named a# and b# but could not find any.  Remember this picture:

         long                                wide
        +---------------+                   +------------------+
        | i   j   a   b |                   | i   a1 a2  b1 b2 |
        |---------------| <--- reshape ---> |------------------|
        | 1   1   1   2 |                   | 1   1   3   2  4 |
        | 1   2   3   4 |                   | 2   5   7   6  8 |
        | 2   1   5   6 |                   +------------------+
        | 2   2   7   8 |
        +---------------+

        long to wide: reshape wide a b, i(i) j(j)    (j existing variable)
        wide to long: reshape long a b, i(i) j(j)    (j    new   variable)
Do you have any idea, advice or help?