Hi all,
I have an unbalanced panel dataset consisting of 217 exporting countries, 172 importing countries, and for 30 years.
I need to expand it by filling missing years, exporters, and importer, to get a balanced panel with a total of 30*217^2 observations.
I tried the command as in
https://www.statalist.org/forums/for...783#post843783
but STATA replies "NOT SORTED"
Kindly find below an example of my dataset where there is 3 exporters, 4 importers, and 4 years.
Basically, I want first to get 4^3= 64 observations (48 observations between country pairs and 16 between themselves), and second to fill exporter's and importer's names for the corresponding missing data.
any help is highly appreciated, thank you so much.
* Example generated by -dataex-. To install: ssc install dataex
clear
input str30(exporter importer) long year double simple float pair_id
"Afghanistan" "Australia" 2014 2.55 1
"Afghanistan" "Australia" 2015 1.68 1
"Afghanistan" "Australia" 2016 3.39 1
"Afghanistan" "Australia" 2017 2.72 1
"Afghanistan" "Chile" 2015 6 2
"Afghanistan" "Chile" 2016 6 2
"Afghanistan" "Chile" 2017 6 2
"Afghanistan" "United States" 2014 3.58 3
"Afghanistan" "United States" 2015 3.45 3
"Afghanistan" "United States" 2016 3.46 3
"Afghanistan" "United States" 2017 2.75 3
"Australia" "Australia" 2014 3.23 4
"Australia" "Australia" 2015 2.94 4
"Australia" "Australia" 2016 3.04 4
"Australia" "Australia" 2017 2.97 4
"Australia" "Chile" 2015 6 5
"Australia" "Chile" 2016 6 5
"Australia" "Chile" 2017 6 5
"Australia" "United States" 2014 3.52 6
"Australia" "United States" 2015 3.45 6
"Australia" "United States" 2016 3.46 6
"Australia" "United States" 2017 3.24 6
"Chile" "Australia" 2014 3.07 7
"Chile" "Australia" 2015 2.81 7
"Chile" "Australia" 2016 2.92 7
"Chile" "Australia" 2017 2.93 7
"Chile" "Chile" 2015 6 8
"Chile" "Chile" 2016 6 8
"Chile" "United States" 2014 3.28 9
"Chile" "United States" 2015 3.16 9
"Chile" "United States" 2016 3.18 9
"Chile" "United States" 2017 6.16 9
end
[/CODE]
------------------ copy up to and including the previous line ------------------
Listed 32 out of 32 observations
I have an unbalanced panel dataset consisting of 217 exporting countries, 172 importing countries, and for 30 years.
I need to expand it by filling missing years, exporters, and importer, to get a balanced panel with a total of 30*217^2 observations.
I tried the command as in
https://www.statalist.org/forums/for...783#post843783
but STATA replies "NOT SORTED"
Kindly find below an example of my dataset where there is 3 exporters, 4 importers, and 4 years.
Basically, I want first to get 4^3= 64 observations (48 observations between country pairs and 16 between themselves), and second to fill exporter's and importer's names for the corresponding missing data.
any help is highly appreciated, thank you so much.
* Example generated by -dataex-. To install: ssc install dataex
clear
input str30(exporter importer) long year double simple float pair_id
"Afghanistan" "Australia" 2014 2.55 1
"Afghanistan" "Australia" 2015 1.68 1
"Afghanistan" "Australia" 2016 3.39 1
"Afghanistan" "Australia" 2017 2.72 1
"Afghanistan" "Chile" 2015 6 2
"Afghanistan" "Chile" 2016 6 2
"Afghanistan" "Chile" 2017 6 2
"Afghanistan" "United States" 2014 3.58 3
"Afghanistan" "United States" 2015 3.45 3
"Afghanistan" "United States" 2016 3.46 3
"Afghanistan" "United States" 2017 2.75 3
"Australia" "Australia" 2014 3.23 4
"Australia" "Australia" 2015 2.94 4
"Australia" "Australia" 2016 3.04 4
"Australia" "Australia" 2017 2.97 4
"Australia" "Chile" 2015 6 5
"Australia" "Chile" 2016 6 5
"Australia" "Chile" 2017 6 5
"Australia" "United States" 2014 3.52 6
"Australia" "United States" 2015 3.45 6
"Australia" "United States" 2016 3.46 6
"Australia" "United States" 2017 3.24 6
"Chile" "Australia" 2014 3.07 7
"Chile" "Australia" 2015 2.81 7
"Chile" "Australia" 2016 2.92 7
"Chile" "Australia" 2017 2.93 7
"Chile" "Chile" 2015 6 8
"Chile" "Chile" 2016 6 8
"Chile" "United States" 2014 3.28 9
"Chile" "United States" 2015 3.16 9
"Chile" "United States" 2016 3.18 9
"Chile" "United States" 2017 6.16 9
end
[/CODE]
------------------ copy up to and including the previous line ------------------
Listed 32 out of 32 observations
Comment