Hello, I am trying to create a panel structure with three dimensions: exporting country, importing county and year. Each country has to be an exporter and an importer over years 2010 to 2015. Note that EX is numeric id for exporter and EXP is letter id for the exporter. The same ids have to be "copied" for the importers as IM and IMP.
Code:
clear
input EX str3 EXP
1 "USA"
2 "CHN"
3 "GBR"
4 "IND"
5 "AUS"
end
forval n= 2010(1)2015 {
gen time`n' = .
}
reshape long time, i(EX) j(YEAR)
drop time
levelsof EX, local(exlist)
foreach i of local exlist {
gen IM_`i' = .
}
reshape long IM_, i(EX YEAR) j(IM)
drop IM_
However, doing this way, letter id for importer as IMP can not be obtain unless merged separately. Nevertheless, there has to be some rather nicer and precise way of doing the whole task. Any help please!
PS: I use Stata 16 on Windows 8.
0 Response to Creating panel structure - any precise way?
Post a Comment