Hello Statalist
I am currently working with the Global Sanction Database, which lists every country that has been hit by sanctions from 1950 to 2022. My issue is that I need this to be panel data. It currently lists one observation pr. instance of sanctions against a country (often multiple instances pr. year), and no observations in the years that the country has not been sanctioned. However I need to create observations for all years, for all countries, with a simple dummy variable (sanctioned/ not sanctioned). Not sanctioned is all the missing years for each country, and sanctioned is all the years where there is observations in the dataset.
Does anyone have a way to to this, without having to do it manually? Ideally I would like to have an extra variable that counts how many instances of sanctions against a country, there has been in any given year.
Thanks in advance.
[CODE]
* Example generated by -dataex-. For more info, type help dataex
clear
input str46 sanctioned_state int year byte(arms military trade financial travel other) long country_id
"Afghanistan" 1979 0 1 0 1 0 0 1
"Afghanistan" 1996 1 0 0 0 0 0 1
"Afghanistan" 1996 1 0 0 0 0 0 1
"Afghanistan" 1996 1 0 0 0 0 0 1
"Afghanistan" 1996 1 0 0 0 0 0 1
"Afghanistan" 1996 1 0 0 0 0 0 1
"Afghanistan" 1996 1 0 0 0 0 0 1
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1951 0 0 1 0 0 0 3
"Albania" 1951 0 0 1 0 0 0 3
"Albania" 1951 0 0 1 0 0 0 3
"Albania" 1951 0 0 1 0 0 0 3
"Albania" 1951 0 0 1 0 0 0 3
"Algeria" 1962 0 0 0 1 0 0 50
"Algeria" 1965 0 0 1 1 0 0 50
"Algeria" 1966 0 0 1 1 0 0 50
"Algeria" 1967 0 0 1 1 0 0 50
"Algeria" 1968 0 0 1 1 0 0 50
"Algeria" 1969 0 0 1 1 0 0 50
"Algeria" 1970 0 0 1 1 0 0 50
"Algeria" 1971 0 0 1 1 0 0 50
"Algeria" 1976 0 0 0 1 0 0 50
"Algeria" 1977 0 0 0 1 0 0 50
"Algeria" 1978 0 0 0 1 0 0 50
"Algeria" 1979 0 0 0 1 0 0 50
"Algeria" 1980 0 0 0 1 0 0 50
"Algeria" 1981 0 0 0 1 0 0 50
"Algeria" 1982 0 0 0 1 0 0 50
"Algeria" 1983 0 0 0 1 0 0 50
"Algeria" 1984 0 0 0 1 0 0 50
"Algeria" 1985 0 0 0 1 0 0 50
"Algeria" 1986 0 0 0 1 0 0 50
"Algeria" 1987 0 0 0 1 0 0 50
"Algeria" 1988 0 0 0 1 0 0 50
"Algeria" 1989 0 0 0 1 0 0 50
"Algeria" 1990 0 0 0 1 0 0 50
I am currently working with the Global Sanction Database, which lists every country that has been hit by sanctions from 1950 to 2022. My issue is that I need this to be panel data. It currently lists one observation pr. instance of sanctions against a country (often multiple instances pr. year), and no observations in the years that the country has not been sanctioned. However I need to create observations for all years, for all countries, with a simple dummy variable (sanctioned/ not sanctioned). Not sanctioned is all the missing years for each country, and sanctioned is all the years where there is observations in the dataset.
Does anyone have a way to to this, without having to do it manually? Ideally I would like to have an extra variable that counts how many instances of sanctions against a country, there has been in any given year.
Thanks in advance.
[CODE]
* Example generated by -dataex-. For more info, type help dataex
clear
input str46 sanctioned_state int year byte(arms military trade financial travel other) long country_id
"Afghanistan" 1979 0 1 0 1 0 0 1
"Afghanistan" 1996 1 0 0 0 0 0 1
"Afghanistan" 1996 1 0 0 0 0 0 1
"Afghanistan" 1996 1 0 0 0 0 0 1
"Afghanistan" 1996 1 0 0 0 0 0 1
"Afghanistan" 1996 1 0 0 0 0 0 1
"Afghanistan" 1996 1 0 0 0 0 0 1
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1950 0 0 1 0 0 0 3
"Albania" 1951 0 0 1 0 0 0 3
"Albania" 1951 0 0 1 0 0 0 3
"Albania" 1951 0 0 1 0 0 0 3
"Albania" 1951 0 0 1 0 0 0 3
"Albania" 1951 0 0 1 0 0 0 3
"Algeria" 1962 0 0 0 1 0 0 50
"Algeria" 1965 0 0 1 1 0 0 50
"Algeria" 1966 0 0 1 1 0 0 50
"Algeria" 1967 0 0 1 1 0 0 50
"Algeria" 1968 0 0 1 1 0 0 50
"Algeria" 1969 0 0 1 1 0 0 50
"Algeria" 1970 0 0 1 1 0 0 50
"Algeria" 1971 0 0 1 1 0 0 50
"Algeria" 1976 0 0 0 1 0 0 50
"Algeria" 1977 0 0 0 1 0 0 50
"Algeria" 1978 0 0 0 1 0 0 50
"Algeria" 1979 0 0 0 1 0 0 50
"Algeria" 1980 0 0 0 1 0 0 50
"Algeria" 1981 0 0 0 1 0 0 50
"Algeria" 1982 0 0 0 1 0 0 50
"Algeria" 1983 0 0 0 1 0 0 50
"Algeria" 1984 0 0 0 1 0 0 50
"Algeria" 1985 0 0 0 1 0 0 50
"Algeria" 1986 0 0 0 1 0 0 50
"Algeria" 1987 0 0 0 1 0 0 50
"Algeria" 1988 0 0 0 1 0 0 50
"Algeria" 1989 0 0 0 1 0 0 50
"Algeria" 1990 0 0 0 1 0 0 50
Comment