Visualising Data in SAS
Week 4 Assignment:
As stated in my previous assignment (Week 3), the dataset I was interested is the ‘Gapminder Data’. For this assignment I would like to go back to the 2 key questions which I had mentioned in my previous blog.
1. Â Is high Life Expectancy associated with high Internet Usage rates?
2.  Is high Life Expectancy associated with high Employment Rate? or in other words should the country having highest Employment rate also have the highest life Expectancy? The rationale behind this would be  - Better the employment opportunities, happier are its citizens and automatically higher is the life Expectancy.
Solutions:
To the find the solution and to kickstart the the analysis, I carried out the Exploratory analysis using SAS.
Accessing the Data Set:
SAS Code:
input:
Step 1 : Importing the ‘Gapminder.csv’ file into SAS using ‘PROC IMPORT’ approach.
The ‘Gapminder.csv’ file was imported as ‘work.gapminder’ dataset in SAS.
SAS Log:
The Observation here refers to all the data of 213 Countries included in this Gapminder Dataset and there are in total 20 variables for each Country such as Income per person, alcohol consumption per adult, armed forces personnel, breast Cancer cases per 100000 females, CO2 emissions, Life expectancy, internet usage rates, Employment rate etc. The complete list of variable is mentioned in the Gapminder Codebook.
Next it was important to Read in the Gapminder Data into SAS in order to access all the required variables. For this  purpose, a new dataset ‘gapminderdata’ was created which could be used for the analysis.
‘work.gapminder’ dataset can viewed as a data table with the help of this SAS code:
SAS Code:
Snapshot of the Dataframe:
Now this ‘gapminderdata’ dataset had all the required variables for the analysis.
To address the above mentioned Questions 1 & 2, It was necessary to address  three key Variables:
1. Life Expectancy of each country The average number of years a newborn child would live if current mortality patterns were to stay the same.
2. Internet Usage Rate in Each Country Internet users (per 100 people). Internet users are people with access to the worldwide network.
3. Employment rate in each Country Percentage of employed people in each country.
Let us first derive the univariate Statistics for each of the above variables.Â
SAS code:
Life Expectancy
Output table from SAS:
Summary
So for the variable ‘Lifeexpectancy’, Total number of countries having a valid life  expectancy data are 191. The mean Life Expectancy from those 191 countries is close to 70 years. However there seems to be less variability with the standard deviation being only 10 years. So Average Life Expectancy among 191 countries is 70 +/- 10 years. Among 191 countries most of them have a life expectancy of about 73 years (Mode).
If we look at the Quantile ranges, we can see that the lowest Life expectancy observed in any country is 48 years and highest life expectancy is recorded to be about 84 years. There are in total about 22 countries where the data about the Life expectancy is completely missing.
We could also make a separate variable - ‘lifeexpectcat’ which will categorise the variable ‘life expectancy’ into different groups-Â
0-50 years
50-60 years
60-70 years
70-80 years
80-80 years
and then produce the Bar-chart for this variable,
SAS code:
Output table from SAS:
Univariate graph of Life Expectancy
From the above Bar-chart, Life expectancy for all countries follows unimodal distribution. we can clearly see that the highest frequency for the Life expectancy or mode lies between 70-80 years. This was also highlighted in the above section where the mode average for the life expectancy was 73 years.Â
Internet Usage Rate
Output table from SAS:
Summary
So for the variable ‘internetuserate’, Total number of countries having a valid life  Internet Use Rate data are 192. The mean Internet Usage Rate from those 192 countries is close to 36%. However there seems to be high variability with the standard deviation being almost the same as the average-  32%. So Average Internet Usage Rate among 192 countries is 36 +/- 32 users out of every 100 people.
If we look at the Quantile ranges, we can see that the lowest internet usage rate observed in any country is 0.21% (2 out of every 10000 people) and highest Internet Usage rate is recorded to be about 96%. There are in total about 21 countries where the data about the Internet usage rate is completely missing.
We could also make a separate variable - ‘internetuseratecat’ which will categorise the variable ‘internetuserate’ into different groups-
Missing data
0-20 %
20-40 %
40-60 %
60-80 %
80-100 %
and then produce the Bar-chart for this variable,
SAS code:
Output table from SAS:
Univariate graph of Internet Usage Rates
From the above Bar-chart, internet usage rate for all countries follows unimodal distribution. we can clearly see that the highest frequency for the Internet usage is below 20%. In other words most of the countries have less than 20 internet users out of every 100 people. The distribution looks more skewed to the right suggesting that there are only few countries with the maximum internet usage rates.Â
Employment rate
Output table from SAS:
Summary
So for the variable ‘employrate’, there are about 178 countries in total with valid employment Rate data. The mean Employment Rate from those 178 countries is close to 59%. There seems to be low variability with the standard deviation accounting for only 10%. So on an average about 59 +/- 10 people out of every 100 are employed. Among 178 countries most of them have an Employment rate of about 47% (Mode).
If we look at the Quantile ranges, we can see that the lowest Employment rate observed in any country is 32% (only 32 out of every 100 people are employed) and highest Employment rate is recorded to be about 83.2%. There are in total about 35 countries where the data about the Employment rate is completely missing.
We could also make a separate variable - ‘employratecat’ which will categorise the variable ‘employrate’ into 3 different groups-
Missing data
0-30 %
30-60 %
60-90 %
and then produce the Bar-chart for this variable,
SAS code:
Output table from SAS:
Univariate graph of Employment Rate
From the above Bar-chart, Employment rate for all countries follows unimodal distribution. we can clearly see that the highest frequency for the Employment rate is between 30-60%. In other words most of the countries have about 30-60 employed people out of every 100 people. There is a significant proportion (16%) of the countries where the employment details are unknown or missing.
Now coming back to the 1st Question:
Is high Life Expectancy associated with high Internet Usage rates? or in other words, Should the countries where maximum internet usage is observed have the highest Life Expectancy (>70 years). Lets check it out:
Since both the variables (Explanatory variable - ‘internetuserate’) and (Response variable - ‘Lifeexpectancy’) are Quantitative, We could simply draw a scatter plot and check for any association.
SAS code:
Scatter plot:
Summary:
The graph above plots the ‘Internet Usage rate’ of a country to the country’s corresponding ‘Life Expectancy’. Those data points inside the Red box are the ones with Highest Internet Usage Rates and they correspondingly share good Life Expectancy. So there seems to be strong positive relationship between the two variables. In other words, with the Increase in the internet usage, one also sees an increase in the Life Expectancy rates.
Answer to 2nd Question:
Is high Life Expectancy associated with high Employment rates? or in other words, Should the countries where there is maximum Employment have the highest Life Expectancy (>70 years). Lets check it out:
Again since both the variables (Explanatory variable - ‘employrate’) and (Response variable - ‘Lifeexpectancy’) are Quantitative, We could simply draw a scatter plot and check for any association.
SAS code:
Scatter Plot:
Summary:
The graph above plots the ‘Employment rate’ of a country to the country’s corresponding ‘Life Expectancy’. We can see that the scatter graph does not show a clear relationship/trend between the two variables.Those data points inside the Red box are the ones with Highest Life Expectancy Rates and they correspondingly share Average Employment Rates but not necessarily the highest  Employment rates.Â













