326.How Fast Is Our Planet Warming? A Data-Driven Climate Change Study in SAS

How Fast Is Our Planet Warming? A Data-Driven Climate Change Study in SAS

 options nocenter;

1) Create raw dataset with date formats 

data climate_raw;

  informat Observation_Date date9.;

  format   Observation_Date date9.;

  input Country :$25. Observation_Date :date9.  CO2_Emissions   :8.2  /* metric tons per capita */

        Average_Temperature :6.2 /*in °C */   Sea_Level_Rise  :8.1  /* mm since baseline year */

        Forest_Cover    :6.2  /*in percent */   Pollution_Index :6.1;

  datalines;

Sweden        01JAN2024  4.90  7.1  9.5  69.0  22.0

India         01JAN2024  1.90  26.8 18.2  24.0  65.5

USA           01JAN2024 14.50 12.3  22.4 33.9  40.2

Bangladesh    01JAN2024  0.50 25.1  35.6  17.0  78.9

Australia     01JAN2024 16.80 21.5  14.0  16.5  36.0

Brazil        01JAN2024  2.10 25.0  10.1  59.4  30.0

Germany       01JAN2024  8.40 10.5  8.8   31.9  28.5

China         01JAN2024  7.60 14.2  16.7  22.3  55.0

Maldives      01JAN2024  2.00 28.3  70.2  32.0  62.0

Ethiopia      01JAN2024  0.30 19.8  12.0  45.0  34.0

Japan         01JAN2024  9.20 13.6  19.1  67.0  29.8

UK            01JAN2024  5.90 10.8  11.4  12.8  35.3

;

run;

proc print data=climate_raw;

run;

OUTPUT:

ObsObservation_DateCountryCO2_EmissionsAverage_TemperatureSea_Level_RiseForest_CoverPollution_Index
101JAN2024Sweden4.97.19.569.022.0
201JAN2024India1.926.818.224.065.5
301JAN2024USA14.512.322.433.940.2
401JAN2024Bangladesh0.525.135.617.078.9
501JAN2024Australia16.821.514.016.536.0
601JAN2024Brazil2.125.010.159.430.0
701JAN2024Germany8.410.58.831.928.5
801JAN2024China7.614.216.722.355.0
901JAN2024Maldives2.028.370.232.062.0
1001JAN2024Ethiopia0.319.812.045.034.0
1101JAN2024Japan9.213.619.167.029.8
1201JAN2024UK5.910.811.412.835.3


2) Add a baseline year and compute 'Years_Since_Baseline' using INTCK 

data climate_raw2;

  set climate_raw;

  /* choose baseline date (e.g., 1990-01-01) for climate comparisons */

  Baseline_Date = '01JAN1990'd;

  format Baseline_Date date9.;

  Years_Since_Baseline = intck('year', Baseline_Date, Observation_Date); /* integer years */

  /* Also create a quarterly-aligned date using INTNX (e.g., shift to quarter start) */

  Obs_QuarterStart = intnx('quarter', Observation_Date, 0, 'b'); /* beginning of quarter */

  format Obs_QuarterStart date9.;

run;

proc print data=climate_raw2;

run;

OUTPUT:

ObsObservation_DateCountryCO2_EmissionsAverage_TemperatureSea_Level_RiseForest_CoverPollution_IndexBaseline_DateYears_Since_BaselineObs_QuarterStart
101JAN2024Sweden4.97.19.569.022.001JAN19903401JAN2024
201JAN2024India1.926.818.224.065.501JAN19903401JAN2024
301JAN2024USA14.512.322.433.940.201JAN19903401JAN2024
401JAN2024Bangladesh0.525.135.617.078.901JAN19903401JAN2024
501JAN2024Australia16.821.514.016.536.001JAN19903401JAN2024
601JAN2024Brazil2.125.010.159.430.001JAN19903401JAN2024
701JAN2024Germany8.410.58.831.928.501JAN19903401JAN2024
801JAN2024China7.614.216.722.355.001JAN19903401JAN2024
901JAN2024Maldives2.028.370.232.062.001JAN19903401JAN2024
1001JAN2024Ethiopia0.319.812.045.034.001JAN19903401JAN2024
1101JAN2024Japan9.213.619.167.029.801JAN19903401JAN2024
1201JAN2024UK5.910.811.412.835.301JAN19903401JAN2024


3) Create a small country_info dataset to demonstrate MERGE (e.g., Region)

data country_info;

  length Country $25 Region $15 Income_Group $10;

  infile datalines dlm='|';

  input Country :$25. Region :$15. Income_Group :$10.;

  datalines;

Sweden|Europe|High

India|Asia|Lower-Middle

USA|North America|High

Bangladesh|Asia|Low

Australia|Oceania|High

Brazil|South America|Upper-Middle

Germany|Europe|High

China|Asia|Upper-Middle

Maldives|Asia|Upper-Middle

Ethiopia|Africa|Low

Japan|Asia|High

UK|Europe|High

;

run;

proc print data=country_info;

run;

OUTPUT:

ObsCountryRegionIncome_Group
1SwedenEuropeHigh
2IndiaAsiaLower-Midd
3USANorth AmericaHigh
4BangladeshAsiaLow
5AustraliaOceaniaHigh
6BrazilSouth AmericaUpper-Midd
7GermanyEuropeHigh
8ChinaAsiaUpper-Midd
9MaldivesAsiaUpper-Midd
10EthiopiaAfricaLow
11JapanAsiaHigh
12UKEuropeHigh


4) Sort datasets for MERGE by Country 

proc sort data=climate_raw2; 

  by Country;

run;

proc print data=climate_raw2;

run;

OUTPUT:

ObsObservation_DateCountryCO2_EmissionsAverage_TemperatureSea_Level_RiseForest_CoverPollution_IndexBaseline_DateYears_Since_BaselineObs_QuarterStart
101JAN2024Australia16.821.514.016.536.001JAN19903401JAN2024
201JAN2024Bangladesh0.525.135.617.078.901JAN19903401JAN2024
301JAN2024Brazil2.125.010.159.430.001JAN19903401JAN2024
401JAN2024China7.614.216.722.355.001JAN19903401JAN2024
501JAN2024Ethiopia0.319.812.045.034.001JAN19903401JAN2024
601JAN2024Germany8.410.58.831.928.501JAN19903401JAN2024
701JAN2024India1.926.818.224.065.501JAN19903401JAN2024
801JAN2024Japan9.213.619.167.029.801JAN19903401JAN2024
901JAN2024Maldives2.028.370.232.062.001JAN19903401JAN2024
1001JAN2024Sweden4.97.19.569.022.001JAN19903401JAN2024
1101JAN2024UK5.910.811.412.835.301JAN19903401JAN2024
1201JAN2024USA14.512.322.433.940.201JAN19903401JAN2024


proc sort data=country_info; 

 by Country; 

run;

proc print data=country_info;

run;

OUTPUT:

ObsCountryRegionIncome_Group
1AustraliaOceaniaHigh
2BangladeshAsiaLow
3BrazilSouth AmericaUpper-Midd
4ChinaAsiaUpper-Midd
5EthiopiaAfricaLow
6GermanyEuropeHigh
7IndiaAsiaLower-Midd
8JapanAsiaHigh
9MaldivesAsiaUpper-Midd
10SwedenEuropeHigh
11UKEuropeHigh
12USANorth AmericaHigh


5) Merge climate indicators with country_info

data climate_merged;

  merge climate_raw2 (in=a) country_info (in=b);

  by Country;

  if a; /* keep only climate records */

run;

proc print data=climate_merged;

run;

OUTPUT:

ObsObservation_DateCountryCO2_EmissionsAverage_TemperatureSea_Level_RiseForest_CoverPollution_IndexBaseline_DateYears_Since_BaselineObs_QuarterStartRegionIncome_Group
101JAN2024Australia16.821.514.016.536.001JAN19903401JAN2024OceaniaHigh
201JAN2024Bangladesh0.525.135.617.078.901JAN19903401JAN2024AsiaLow
301JAN2024Brazil2.125.010.159.430.001JAN19903401JAN2024South AmericaUpper-Midd
401JAN2024China7.614.216.722.355.001JAN19903401JAN2024AsiaUpper-Midd
501JAN2024Ethiopia0.319.812.045.034.001JAN19903401JAN2024AfricaLow
601JAN2024Germany8.410.58.831.928.501JAN19903401JAN2024EuropeHigh
701JAN2024India1.926.818.224.065.501JAN19903401JAN2024AsiaLower-Midd
801JAN2024Japan9.213.619.167.029.801JAN19903401JAN2024AsiaHigh
901JAN2024Maldives2.028.370.232.062.001JAN19903401JAN2024AsiaUpper-Midd
1001JAN2024Sweden4.97.19.569.022.001JAN19903401JAN2024EuropeHigh
1101JAN2024UK5.910.811.412.835.301JAN19903401JAN2024EuropeHigh
1201JAN2024USA14.512.322.433.940.201JAN19903401JAN2024North AmericaHigh


6) Compute a composite 'Risk_Score' using z-scores (standardization)

6a) Get means and std devs into a dataset via PROC MEANS 

proc means data=climate_merged noprint;

  var CO2_Emissions Average_Temperature Sea_Level_Rise Forest_Cover Pollution_Index;

  output out=stats mean=mean_CO2 mean_Temp mean_SL mean_Forest mean_Poll

                   std=std_CO2 std_Temp std_SL std_Forest std_Poll;

run;

proc print data=stats;

run;

OUTPUT:

Obs_TYPE__FREQ_mean_CO2mean_Tempmean_SLmean_Forestmean_Pollstd_CO2std_Tempstd_SLstd_Foreststd_Poll
10126.17517.916720.666735.943.15.385697.3332217.284919.833017.8161


6b) Load stats into macro variables for later use 

data _null_;

  set stats;

  call symputx('mean_CO2', mean_CO2);

  call symputx('std_CO2', std_CO2);

  call symputx('mean_Temp', mean_Temp);

  call symputx('std_Temp', std_Temp);

  call symputx('mean_SL', mean_SL);

  call symputx('std_SL', std_SL);

  call symputx('mean_Forest', mean_Forest);

  call symputx('std_Forest', std_Forest);

  call symputx('mean_Poll', mean_Poll);

  call symputx('std_Poll', std_Poll);

run;

LOG:

NOTE: There were 1 observations read from the data set WORK.STATS.

6c) Create z-scores and composite risk (weights can be customized) 

data climate_scores;

  set climate_merged;

  /* avoid division by zero */

  z_CO2   = (CO2_Emissions - &mean_CO2.) / ( &std_CO2.    + 1e-8 );

  z_Temp  = (Average_Temperature - &mean_Temp.) / ( &std_Temp.   + 1e-8 );

  z_SL    = (Sea_Level_Rise - &mean_SL.) / ( &std_SL.      + 1e-8 );

  /* lower Forest_Cover => higher risk, so invert */

  z_Forest = -1 * (Forest_Cover - &mean_Forest.) / ( &std_Forest. + 1e-8 );

  z_Poll  = (Pollution_Index - &mean_Poll.) / ( &std_Poll.     + 1e-8 );


  /* Weighted composite score (weights sum to 1) */

  Risk_Score = 0.30*z_CO2 + 0.25*z_Temp + 0.20*z_SL + 0.15*z_Forest + 0.10*z_Poll;


  /* scale Risk_Score to 0-100 for readability */

  minRisk = .; maxRisk = .;

run;

proc print data=climate_scores;

run;

OUTPUT:

ObsObservation_DateCountryCO2_EmissionsAverage_TemperatureSea_Level_RiseForest_CoverPollution_IndexBaseline_DateYears_Since_BaselineObs_QuarterStartRegionIncome_Groupz_CO2z_Tempz_SLz_Forestz_PollRisk_ScoreminRiskmaxRisk
101JAN2024Australia16.821.514.016.536.001JAN19903401JAN2024OceaniaHigh1.972820.48864-0.385690.97817-0.398520.74374..
201JAN2024Bangladesh0.525.135.617.078.901JAN19903401JAN2024AsiaLow-1.053720.979560.863960.952962.009410.44545..
301JAN2024Brazil2.125.010.159.430.001JAN19903401JAN2024South AmericaUpper-Midd-0.756630.96592-0.61133-1.18489-0.73529-0.35904..
401JAN2024China7.614.216.722.355.001JAN19903401JAN2024AsiaUpper-Midd0.26459-0.50683-0.229490.685720.667930.07642..
501JAN2024Ethiopia0.319.812.045.034.001JAN19903401JAN2024AfricaLow-1.090850.25682-0.50140-0.45883-0.51077-0.48323..
601JAN2024Germany8.410.58.831.928.501JAN19903401JAN2024EuropeHigh0.41313-1.01138-0.686540.20168-0.81948-0.31791..
701JAN2024India1.926.818.224.065.501JAN19903401JAN2024AsiaLower-Midd-0.793771.21138-0.142710.600011.257290.25190..
801JAN2024Japan9.213.619.167.029.801JAN19903401JAN2024AsiaHigh0.56167-0.58865-0.09064-1.56809-0.74651-0.30665..
901JAN2024Maldives2.028.370.232.062.001JAN19903401JAN2024AsiaUpper-Midd-0.775201.415932.865710.196641.060840.83014..
1001JAN2024Sweden4.97.19.569.022.001JAN19903401JAN2024EuropeHigh-0.23674-1.47502-0.64604-1.66893-1.18432-0.93776..
1101JAN2024UK5.910.811.412.835.301JAN19903401JAN2024EuropeHigh-0.05106-0.97047-0.536111.16472-0.43781-0.23423..
1201JAN2024USA14.512.322.433.940.201JAN19903401JAN2024North AmericaHigh1.54576-0.765920.100280.10084-0.162770.29115..


7) Determine percentile ranks using PROC RANK and then categorize risk using a macro 

proc rank data=climate_scores out=climate_rank ties=mean percent;

  var Risk_Score;

  ranks Risk_Pct; /* 0-100 scale percentiles (0..99) */

run;

proc print data=climate_rank;

run;

OUTPUT:

ObsObservation_DateCountryCO2_EmissionsAverage_TemperatureSea_Level_RiseForest_CoverPollution_IndexBaseline_DateYears_Since_BaselineObs_QuarterStartRegionIncome_Groupz_CO2z_Tempz_SLz_Forestz_PollRisk_ScoreminRiskmaxRiskRisk_Pct
101JAN2024Australia16.821.514.016.536.001JAN19903401JAN2024OceaniaHigh1.972820.48864-0.385690.97817-0.398520.74374..91.667
201JAN2024Bangladesh0.525.135.617.078.901JAN19903401JAN2024AsiaLow-1.053720.979560.863960.952962.009410.44545..83.333
301JAN2024Brazil2.125.010.159.430.001JAN19903401JAN2024South AmericaUpper-Midd-0.756630.96592-0.61133-1.18489-0.73529-0.35904..25.000
401JAN2024China7.614.216.722.355.001JAN19903401JAN2024AsiaUpper-Midd0.26459-0.50683-0.229490.685720.667930.07642..58.333
501JAN2024Ethiopia0.319.812.045.034.001JAN19903401JAN2024AfricaLow-1.090850.25682-0.50140-0.45883-0.51077-0.48323..16.667
601JAN2024Germany8.410.58.831.928.501JAN19903401JAN2024EuropeHigh0.41313-1.01138-0.686540.20168-0.81948-0.31791..33.333
701JAN2024India1.926.818.224.065.501JAN19903401JAN2024AsiaLower-Midd-0.793771.21138-0.142710.600011.257290.25190..66.667
801JAN2024Japan9.213.619.167.029.801JAN19903401JAN2024AsiaHigh0.56167-0.58865-0.09064-1.56809-0.74651-0.30665..41.667
901JAN2024Maldives2.028.370.232.062.001JAN19903401JAN2024AsiaUpper-Midd-0.775201.415932.865710.196641.060840.83014..100.000
1001JAN2024Sweden4.97.19.569.022.001JAN19903401JAN2024EuropeHigh-0.23674-1.47502-0.64604-1.66893-1.18432-0.93776..8.333
1101JAN2024UK5.910.811.412.835.301JAN19903401JAN2024EuropeHigh-0.05106-0.97047-0.536111.16472-0.43781-0.23423..50.000
1201JAN2024USA14.512.322.433.940.201JAN19903401JAN2024North AmericaHigh1.54576-0.765920.100280.10084-0.162770.29115..75.000


7a) Macro to categorize into Low/Moderate/High/Severe using Risk_Pct 

%macro categorize(in=, out=, pctvar=Risk_Pct);

  data &out.;

    set &in.;

    length Risk_Category $10.;

    if &pctvar. < 25 then Risk_Category = 'Low';

    else if 25 <= &pctvar. < 50 then Risk_Category = 'Moderate';

    else if 50 <= &pctvar. < 75 then Risk_Category = 'High';

    else Risk_Category = 'Severe';

  run;

  proc print data=&out.;

  run;

%mend categorize;


%categorize(in=climate_rank, out=climate_final, pctvar=Risk_Pct);

OUTPUT:

ObsObservation_DateCountryCO2_EmissionsAverage_TemperatureSea_Level_RiseForest_CoverPollution_IndexBaseline_DateYears_Since_BaselineObs_QuarterStartRegionIncome_Groupz_CO2z_Tempz_SLz_Forestz_PollRisk_ScoreminRiskmaxRiskRisk_PctRisk_Category
101JAN2024Australia16.821.514.016.536.001JAN19903401JAN2024OceaniaHigh1.972820.48864-0.385690.97817-0.398520.74374..91.667Severe
201JAN2024Bangladesh0.525.135.617.078.901JAN19903401JAN2024AsiaLow-1.053720.979560.863960.952962.009410.44545..83.333Severe
301JAN2024Brazil2.125.010.159.430.001JAN19903401JAN2024South AmericaUpper-Midd-0.756630.96592-0.61133-1.18489-0.73529-0.35904..25.000Moderate
401JAN2024China7.614.216.722.355.001JAN19903401JAN2024AsiaUpper-Midd0.26459-0.50683-0.229490.685720.667930.07642..58.333High
501JAN2024Ethiopia0.319.812.045.034.001JAN19903401JAN2024AfricaLow-1.090850.25682-0.50140-0.45883-0.51077-0.48323..16.667Low
601JAN2024Germany8.410.58.831.928.501JAN19903401JAN2024EuropeHigh0.41313-1.01138-0.686540.20168-0.81948-0.31791..33.333Moderate
701JAN2024India1.926.818.224.065.501JAN19903401JAN2024AsiaLower-Midd-0.793771.21138-0.142710.600011.257290.25190..66.667High
801JAN2024Japan9.213.619.167.029.801JAN19903401JAN2024AsiaHigh0.56167-0.58865-0.09064-1.56809-0.74651-0.30665..41.667Moderate
901JAN2024Maldives2.028.370.232.062.001JAN19903401JAN2024AsiaUpper-Midd-0.775201.415932.865710.196641.060840.83014..100.000Severe
1001JAN2024Sweden4.97.19.569.022.001JAN19903401JAN2024EuropeHigh-0.23674-1.47502-0.64604-1.66893-1.18432-0.93776..8.333Low
1101JAN2024UK5.910.811.412.835.301JAN19903401JAN2024EuropeHigh-0.05106-0.97047-0.536111.16472-0.43781-0.23423..50.000High
1201JAN2024USA14.512.322.433.940.201JAN19903401JAN2024North AmericaHigh1.54576-0.765920.100280.10084-0.162770.29115..75.000Severe


8) Append an extra observation (simulating newly collected data) using PROC APPEND 

data new_obs;

  informat Observation_Date date9.;

  format Observation_Date date9.;

  Country = 'Fiji';

  Observation_Date = '01JAN2024'd;

  CO2_Emissions=1.70;

  Average_Temperature=26.6;

  Sea_Level_Rise=40.2; 

  Forest_Cover=50.0; 

  Pollution_Index=45.0;

run;

proc print data=new_obs;

run;

OUTPUT:

ObsObservation_DateCountryCO2_EmissionsAverage_TemperatureSea_Level_RiseForest_CoverPollution_Index
101JAN2024Fiji1.726.640.25045

/* Append to climate_final */

proc append base=climate_final 

            data=new_obs force;

run;

proc print data=climate_final ;

run;

OUTPUT:

ObsObservation_DateCountryCO2_EmissionsAverage_TemperatureSea_Level_RiseForest_CoverPollution_IndexBaseline_DateYears_Since_BaselineObs_QuarterStartRegionIncome_Groupz_CO2z_Tempz_SLz_Forestz_PollRisk_ScoreminRiskmaxRiskRisk_PctRisk_Category
101JAN2024Australia16.821.514.016.536.001JAN19903401JAN2024OceaniaHigh1.972820.48864-0.385690.97817-0.398520.74374..91.667Severe
201JAN2024Bangladesh0.525.135.617.078.901JAN19903401JAN2024AsiaLow-1.053720.979560.863960.952962.009410.44545..83.333Severe
301JAN2024Brazil2.125.010.159.430.001JAN19903401JAN2024South AmericaUpper-Midd-0.756630.96592-0.61133-1.18489-0.73529-0.35904..25.000Moderate
401JAN2024China7.614.216.722.355.001JAN19903401JAN2024AsiaUpper-Midd0.26459-0.50683-0.229490.685720.667930.07642..58.333High
501JAN2024Ethiopia0.319.812.045.034.001JAN19903401JAN2024AfricaLow-1.090850.25682-0.50140-0.45883-0.51077-0.48323..16.667Low
601JAN2024Germany8.410.58.831.928.501JAN19903401JAN2024EuropeHigh0.41313-1.01138-0.686540.20168-0.81948-0.31791..33.333Moderate
701JAN2024India1.926.818.224.065.501JAN19903401JAN2024AsiaLower-Midd-0.793771.21138-0.142710.600011.257290.25190..66.667High
801JAN2024Japan9.213.619.167.029.801JAN19903401JAN2024AsiaHigh0.56167-0.58865-0.09064-1.56809-0.74651-0.30665..41.667Moderate
901JAN2024Maldives2.028.370.232.062.001JAN19903401JAN2024AsiaUpper-Midd-0.775201.415932.865710.196641.060840.83014..100.000Severe
1001JAN2024Sweden4.97.19.569.022.001JAN19903401JAN2024EuropeHigh-0.23674-1.47502-0.64604-1.66893-1.18432-0.93776..8.333Low
1101JAN2024UK5.910.811.412.835.301JAN19903401JAN2024EuropeHigh-0.05106-0.97047-0.536111.16472-0.43781-0.23423..50.000High
1201JAN2024USA14.512.322.433.940.201JAN19903401JAN2024North AmericaHigh1.54576-0.765920.100280.10084-0.162770.29115..75.000Severe
1301JAN2024Fiji1.726.640.250.045.0...  ......... 


9) Use PROC SQL to create a summary table by Region & Income_Group 

proc sql;

  create table region_summary as

  select Region, Income_Group,

         count(*) as N,

         mean(CO2_Emissions) as Mean_CO2 format=8.2,

         mean(Average_Temperature) as Mean_Temp format=8.2,

         mean(Sea_Level_Rise) as Mean_SL format=8.2,

         mean(Forest_Cover) as Mean_Forest format=8.2,

         mean(Pollution_Index) as Mean_Poll format=8.2

  from climate_final

  group by Region, Income_Group

  order by Region;

quit;

proc print data=region_summary;

run;

OUTPUT:

ObsRegionIncome_GroupNMean_CO2Mean_TempMean_SLMean_ForestMean_Poll
1  11.7026.6040.2050.0045.00
2AfricaLow10.3019.8012.0045.0034.00
3AsiaHigh19.2013.6019.1067.0029.80
4AsiaLow10.5025.1035.6017.0078.90
5AsiaLower-Midd11.9026.8018.2024.0065.50
6AsiaUpper-Midd24.8021.2543.4527.1558.50
7EuropeHigh36.409.479.9037.9028.60
8North AmericaHigh114.5012.3022.4033.9040.20
9OceaniaHigh116.8021.5014.0016.5036.00
10South AmericaUpper-Midd12.1025.0010.1059.4030.00


10) Correlation matrix to explore relationships 

proc corr data=climate_final nosimple plots=matrix(histogram);

  var CO2_Emissions Average_Temperature Sea_Level_Rise Forest_Cover Pollution_Index;

run;

OUTPUT:

The CORR Procedure

5 Variables:CO2_Emissions Average_Temperature Sea_Level_Rise Forest_Cover Pollution_Index
Pearson Correlation Coefficients, N = 13
Prob > |r| under H0: Rho=0
 CO2_EmissionsAverage_TemperatureSea_Level_RiseForest_CoverPollution_Index
CO2_Emissions
1.00000
 
-0.47774
0.0987
-0.31052
0.3018
-0.18307
0.5494
-0.37300
0.2094
Average_Temperature
-0.47774
0.0987
1.00000
 
0.59813
0.0308
-0.16870
0.5817
0.62744
0.0217
Sea_Level_Rise
-0.31052
0.3018
0.59813
0.0308
1.00000
 
-0.12244
0.6903
0.60689
0.0278
Forest_Cover
-0.18307
0.5494
-0.16870
0.5817
-0.12244
0.6903
1.00000
 
-0.57290
0.0407
Pollution_Index
-0.37300
0.2094
0.62744
0.0217
0.60689
0.0278
-0.57290
0.0407
1.00000
 
Scatter Plot Matrix


11) Regression: model CO2_Emissions as a function of other indicators 

proc reg data=climate_final;

  model CO2_Emissions = Average_Temperature Sea_Level_Rise Forest_Cover Pollution_Index / vif collin;

  output out=reg_out p=Predicted_CO2 r=Residual;

run;

quit;

OUTPUT:

The REG Procedure

Model: MODEL1

Dependent Variable: CO2_Emissions

Number of Observations Read13
Number of Observations Used13
Analysis of Variance
SourceDFSum of
Squares
Mean
Square
F ValuePr > F
Model4141.3368235.334211.440.3054
Error8196.2108724.52636  
Corrected Total12337.54769   
Root MSE4.95241R-Square0.4187
Dependent Mean5.83077Adj R-Sq0.1281
Coeff Var84.93578  
Parameter Estimates
VariableDFParameter
Estimate
Standard
Error
t ValuePr > |t|Variance
Inflation
Intercept122.531907.545452.990.01740
Average_Temperature1-0.202530.26974-0.750.47431.96136
Sea_Level_Rise10.050580.114570.440.67051.94720
Forest_Cover1-0.154780.09790-1.580.15251.76263
Pollution_Index1-0.192710.15156-1.270.23933.27311
Collinearity Diagnostics
NumberEigenvalueCondition
Index
Proportion of Variation
InterceptAverage_TemperatureSea_Level_RiseForest_CoverPollution_Index
14.405331.000000.001620.003210.007800.004540.00184
20.371873.441870.005060.002740.153520.169260.00754
30.155165.328470.022160.021500.561550.124020.05199
40.049849.401910.106290.925340.088840.002610.08517
50.0178115.728160.864880.047220.188300.699570.85348

The REG Procedure

Model: MODEL1

Dependent Variable: CO2_Emissions

Panel of fit diagnostics for CO2_Emissions.
Panel of scatterplots of residuals by regressors for CO2_Emissions.

12) Visualization: scatter matrix and a scatter + regression line for CO2 vs Temp 

proc sgscatter data=climate_final;

  matrix CO2_Emissions Average_Temperature Sea_Level_Rise Forest_Cover Pollution_Index

                    / diagonal=(histogram);

run;

OUTPUT:

The SGScatter Procedure


/* Scatter + fitted line */

proc sgplot data=reg_out;

  title "CO2 Emissions vs Average Temperature with Regression Line";

  scatter x=Average_Temperature y=CO2_Emissions / datalabel=Country;

  reg x=Average_Temperature y=CO2_Emissions / CLI CLM;

  xaxis label="Average Temperature (°C)";

  yaxis label="CO2 Emissions (metric tons per capita)";

run;

title;

OUTPUT:

The SGPlot Procedure


13) Final dataset view 

proc print data=climate_final label noobs;

  var Country Region Income_Group Observation_Date CO2_Emissions Average_Temperature

      Sea_Level_Rise Forest_Cover Pollution_Index Risk_Score Risk_Pct Risk_Category;

  label CO2_Emissions = "CO2 (t per capita)";

run;

OUTPUT:

CountryRegionIncome_GroupObservation_DateCO2 (t per capita)Average_TemperatureSea_Level_RiseForest_CoverPollution_IndexRisk_ScoreRank for Variable Risk_ScoreRisk_Category
AustraliaOceaniaHigh01JAN202416.821.514.016.536.00.7437491.667Severe
BangladeshAsiaLow01JAN20240.525.135.617.078.90.4454583.333Severe
BrazilSouth AmericaUpper-Midd01JAN20242.125.010.159.430.0-0.3590425.000Moderate
ChinaAsiaUpper-Midd01JAN20247.614.216.722.355.00.0764258.333High
EthiopiaAfricaLow01JAN20240.319.812.045.034.0-0.4832316.667Low
GermanyEuropeHigh01JAN20248.410.58.831.928.5-0.3179133.333Moderate
IndiaAsiaLower-Midd01JAN20241.926.818.224.065.50.2519066.667High
JapanAsiaHigh01JAN20249.213.619.167.029.8-0.3066541.667Moderate
MaldivesAsiaUpper-Midd01JAN20242.028.370.232.062.00.83014100.000Severe
SwedenEuropeHigh01JAN20244.97.19.569.022.0-0.937768.333Low
UKEuropeHigh01JAN20245.910.811.412.835.3-0.2342350.000High
USANorth AmericaHigh01JAN202414.512.322.433.940.20.2911575.000Severe
Fiji  01JAN20241.726.640.250.045.0.. 




To Visit My Previous Original Data Management Dataset:Click Here
To Visit My Previous Cricket World Cup Dataset:Click Here
To Visit My Previous Home Tour Dataset:Click Here
To Visit My Previous Real-World Dal Price Dataset:Click Here  



Follow Us On : 


 


--- FOLLOW OUR BLOG FOR MORE INFORMATION.

--->PLEASE DO COMMENTS AND SHARE OUR BLOG.









Comments

Popular posts from this blog

409.Can We Build a Reliable Emergency Services Analytics & Fraud Detection System in SAS While Identifying and Fixing Intentional Errors?

397.If a satellite has excellent signal strength but very high latency, can it still deliver good quality communication? Why or why not?A Sas Study

401.How Efficient Are Global Data Centers? A Complete SAS Analytics Study