Week 2 assignment asks to submit frequency distribution programs for 3 data variables and describe the output in terms of the values the variables take, how often they take them and the presence of missing data.
The program creates 3 frequency distributions and 1 cross table distribution
Program
LIBNAME mydata "/courses/d1406ae5ba27fe300 " access=readonly;
DATA new; set mydata.gapminder;
/*
Insert meaningful lables to the variables
*/
label country="country"
oilperperson="Oil per person"
incomeperperson="Income per person ($) (based on 2010 dollar exchange rate)"
incomecategory="Income category"
polityscore="Democracy score"
armedforcesrate="Armed forces personnel";
run;
/*
Formatting the dataset to make it ready for frequency distribution
*/
proc format;
value incomecategory
low-<5000 = 'Less than 5000'
5000-<10000 = '5000 to 10000'
10000-<15000 = '10000 to 15000'
15000-<20000 = '15000 to 20000'
20000-<30000 = '20000 to 30000'
30000-high = '30000 and higher'
.='Missing';
value oilcategory
low-<2 = 'Less than 2 tonnes per year'
2-<4 = 'Between 2 and 4 tonnes per year'
4-<6 = 'Between 4 and 6 tonnes per year'
6-<8 = 'Between 6 and 8 tonnes per year'
8-high = 'Greater than 8 tonnes per year'
.='Missing';
value politycategory
.='Missing';
run;
/*Do a frequency distribution*/
Title 'All country income distribution categorised';
PROC FREQ Data=new;
TABLES incomeperperson / missing;
format incomeperperson incomecategory.;
run;
Title 'All country Oil consumption per person categorised';
PROC FREQ Data=new;
TABLES oilperperson / missing;
format oilperperson oilcategory.;
run;
Title 'All country democracy score categorised';
PROC FREQ Data=new order=freq;
TABLES polityscore / missing;
format polityscore politycategory.;
run;
/*
Cross table frequency distribution.
This distribution shows the count of countries
cross tabulated by democracy score and income per person.
*/
Title 'All country democracy score by income per person categorised';
PROC FREQ Data=new;
TABLES polityscore * incomeperperson / nopercent nocum nocol norow missing;
format polityscore politycategory.;
format incomeperperson incomecategory.;
run;
Income per person frequency distribution
Summary: This distribution shows the income per person distribution across all countries in the gapminder data set.
Note that each countries income per person data is based on the dollar exchange rate as of 2010. This fact is mentioned in the world bank data source used in the gapminder data set.
Noticeable points are
- There are 23 missing observations. This means that 23 countries in the dataset have missing information on the income per person data in the gapminder dataset.
- 115 countries (54%) have income below $5000.
- There are 16 countries (7.5%) with income above $30000.
Oil consumption per person
Summary: This distribution shows the oil consumption per person distribution across all countries in the gapminder data set.
Note that 1 Tonne = 1000 Kilograms.
Noticeable points are
- There are 150 countries where the oil consumption data is missing.
- 51 countries (24%) consume less than 2 tonnes per person per year
- 1 country (0.5%) consumes greater than 8 tonnes per year. This country happens to be Singapore!!. Interesting.
Democracy score distribution
Summary: This distribution shows the frequency distribution arranged in descending order of the frequency count. Here I was interested in which democracy score was at the top score in terms of number of countries.
Noticeable points are
- There are 52 countries (24.4%) with missing data.
- 33 countries (15%) have a high democracy score posted of 10.
- Only 2 countries scored an extreme democracy score of -10. These happen to be 2 Middle East countries i.e. Qatar and Saudi Arabia. This fact draws me closer to the claim made by Michael L.Ross in his paper "Does Oil hinder democracy?".
Democracy score versus income per person
Summary: This distribution shows the cross tabulated frequency count of democracy score versus income per person.
Noticeable points are
- 17 countries have both missing democracy score and income per person data points in the gapminder dataset.
- The interesting data points are the ones at the extreme ends of the diagonal i.e. countries which show high income but the lowest on the democracy scale and vice versa. These two countries happen to be Saudi Arabia and Mongolia respectively. Interesting fact.
- Another interesting fact is that many of the countries score a high democracy i.e. between 5 to 10 and have low income per person suggesting probably another factor other than income could be driving the high democracy scores for these countries. This causal relationship has also been studied by Daron et al.in their paper "Income and Democracy".
Comments
Post a Comment