DISTRIBUTION ANALYSIS OF WAR OUTCOMES USING DATA STEP | PROQ MEANS | PROC UNIVARIATE | MACROS | PROC SQL | PROC GCHART | PROC FREQ FOR GRAPHICAL AND FREQUENCY-BASED SUMMARIZATION
options nocenter;
1.HISTORICAL WARS DATASET CREATION
data historical_wars;
length War_Name $40 Outcome $25;
format Start_Date End_Date date9.;
input War_Name $ Start_Date :date9. End_Date :date9.
Countries_Involved Casualties Outcome $;
Year = year(Start_Date);
Duration_Days = intck('day', Start_Date, End_Date);
datalines;
World_War_I 28JUL1914 11NOV1918 30 20000000 Allied_Victory
World_War_II 01SEP1939 02SEP1945 50 70000000 Allied_Victory
Cold_War 12MAR1947 26DEC1991 45 2000000 Ideological_End
Vietnam_War 01NOV1955 30APR1975 10 3000000 Communist_Victory
Korean_War 25JUN1950 27JUL1953 20 1500000 Armistice
Gulf_War 02AUG1990 28FEB1991 35 25000 Coalition_Victory
Afghan_War_US 07OCT2001 30AUG2021 40 240000 Taliban_Victory
Iran_Iraq_War 22SEP1980 20AUG1988 2 1000000 Stalemate
Napoleonic_Wars 18MAY1803 20NOV1815 25 6000000 Coalition_Victory
Crimean_War 16OCT1853 30MAR1856 6 500000 Allied_Victory
Franco_Prussian 19JUL1870 28JAN1871 2 180000 German_Victory
Russo_Japanese 08FEB1904 05SEP1905 2 150000 Japanese_Victory
;
run;
proc print data=historical_wars;
run;
OUTPUT:
| Obs | War_Name | Outcome | Start_Date | End_Date | Countries_Involved | Casualties | Year | Duration_Days |
|---|---|---|---|---|---|---|---|---|
| 1 | World_War_I | Allied_Victory | 28JUL1914 | 11NOV1918 | 30 | 20000000 | 1914 | 1567 |
| 2 | World_War_II | Allied_Victory | 01SEP1939 | 02SEP1945 | 50 | 70000000 | 1939 | 2193 |
| 3 | Cold_War | Ideological_End | 12MAR1947 | 26DEC1991 | 45 | 2000000 | 1947 | 16360 |
| 4 | Vietnam_War | Communist_Victory | 01NOV1955 | 30APR1975 | 10 | 3000000 | 1955 | 7120 |
| 5 | Korean_War | Armistice | 25JUN1950 | 27JUL1953 | 20 | 1500000 | 1950 | 1128 |
| 6 | Gulf_War | Coalition_Victory | 02AUG1990 | 28FEB1991 | 35 | 25000 | 1990 | 210 |
| 7 | Afghan_War_US | Taliban_Victory | 07OCT2001 | 30AUG2021 | 40 | 240000 | 2001 | 7267 |
| 8 | Iran_Iraq_War | Stalemate | 22SEP1980 | 20AUG1988 | 2 | 1000000 | 1980 | 2889 |
| 9 | Napoleonic_Wars | Coalition_Victory | 18MAY1803 | 20NOV1815 | 25 | 6000000 | 1803 | 4569 |
| 10 | Crimean_War | Allied_Victory | 16OCT1853 | 30MAR1856 | 6 | 500000 | 1853 | 896 |
| 11 | Franco_Prussian | German_Victory | 19JUL1870 | 28JAN1871 | 2 | 180000 | 1870 | 193 |
| 12 | Russo_Japanese | Japanese_Victory | 08FEB1904 | 05SEP1905 | 2 | 150000 | 1904 | 575 |
2.PROC SQL – DATA EXTRACTION AND DERIVED COLUMNS
proc sql;
create table wars_sql as
select War_Name,Year,Countries_Involved,Casualties,Duration_Days,Outcome,
intnx('year', Start_Date, 1) as Next_Year_Start format=date9.
from historical_wars;
quit;
proc print data=wars_sql;
run;
OUTPUT:
| Obs | War_Name | Year | Countries_Involved | Casualties | Duration_Days | Outcome | Next_Year_Start |
|---|---|---|---|---|---|---|---|
| 1 | World_War_I | 1914 | 30 | 20000000 | 1567 | Allied_Victory | 01JAN1915 |
| 2 | World_War_II | 1939 | 50 | 70000000 | 2193 | Allied_Victory | 01JAN1940 |
| 3 | Cold_War | 1947 | 45 | 2000000 | 16360 | Ideological_End | 01JAN1948 |
| 4 | Vietnam_War | 1955 | 10 | 3000000 | 7120 | Communist_Victory | 01JAN1956 |
| 5 | Korean_War | 1950 | 20 | 1500000 | 1128 | Armistice | 01JAN1951 |
| 6 | Gulf_War | 1990 | 35 | 25000 | 210 | Coalition_Victory | 01JAN1991 |
| 7 | Afghan_War_US | 2001 | 40 | 240000 | 7267 | Taliban_Victory | 01JAN2002 |
| 8 | Iran_Iraq_War | 1980 | 2 | 1000000 | 2889 | Stalemate | 01JAN1981 |
| 9 | Napoleonic_Wars | 1803 | 25 | 6000000 | 4569 | Coalition_Victory | 01JAN1804 |
| 10 | Crimean_War | 1853 | 6 | 500000 | 896 | Allied_Victory | 01JAN1854 |
| 11 | Franco_Prussian | 1870 | 2 | 180000 | 193 | German_Victory | 01JAN1871 |
| 12 | Russo_Japanese | 1904 | 2 | 150000 | 575 | Japanese_Victory | 01JAN1905 |
3.PROC FREQ – OUTCOME DISTRIBUTION
proc freq data=historical_wars;
tables Outcome / nocum nopercent;
run;
OUTPUT:
The FREQ Procedure
| Outcome | Frequency |
|---|---|
| Allied_Victory | 3 |
| Armistice | 1 |
| Coalition_Victory | 2 |
| Communist_Victory | 1 |
| German_Victory | 1 |
| Ideological_End | 1 |
| Japanese_Victory | 1 |
| Stalemate | 1 |
| Taliban_Victory | 1 |
4.PROC MEANS – DESCRIPTIVE STATISTICS
proc means data=historical_wars mean min max sum;
var Casualties Duration_Days Countries_Involved;
run;
OUTPUT:
The MEANS Procedure
| Variable | Mean | Minimum | Maximum | Sum |
|---|---|---|---|---|
Casualties Duration_Days Countries_Involved | 8716250.00 3747.25 22.2500000 | 25000.00 193.0000000 2.0000000 | 70000000.00 16360.00 50.0000000 | 104595000 44967.00 267.0000000 |
5.PROC UNIVARIATE – DISTRIBUTION ANALYSIS
proc univariate data=historical_wars;
var Casualties;
histogram Casualties;
run;
OUTPUT:
The UNIVARIATE Procedure
Variable: Casualties
| Moments | |||
|---|---|---|---|
| N | 12 | Sum Weights | 12 |
| Mean | 8716250 | Sum Observations | 104595000 |
| Std Deviation | 20092823.1 | Variance | 4.03722E14 |
| Skewness | 3.0552289 | Kurtosis | 9.65331645 |
| Uncorrected SS | 5.35261E15 | Corrected SS | 4.44094E15 |
| Coeff Variation | 230.521418 | Std Error Mean | 5800298.42 |
| Basic Statistical Measures | |||
|---|---|---|---|
| Location | Variability | ||
| Mean | 8716250 | Std Deviation | 20092823 |
| Median | 1250000 | Variance | 4.03722E14 |
| Mode | . | Range | 69975000 |
| Interquartile Range | 4290000 | ||
| Tests for Location: Mu0=0 | ||||
|---|---|---|---|---|
| Test | Statistic | p Value | ||
| Student's t | t | 1.502724 | Pr > |t| | 0.1611 |
| Sign | M | 6 | Pr >= |M| | 0.0005 |
| Signed Rank | S | 39 | Pr >= |S| | 0.0005 |
| Quantiles (Definition 5) | |
|---|---|
| Level | Quantile |
| 100% Max | 70000000 |
| 99% | 70000000 |
| 95% | 70000000 |
| 90% | 20000000 |
| 75% Q3 | 4500000 |
| 50% Median | 1250000 |
| 25% Q1 | 210000 |
| 10% | 150000 |
| 5% | 25000 |
| 1% | 25000 |
| 0% Min | 25000 |
| Extreme Observations | |||
|---|---|---|---|
| Lowest | Highest | ||
| Value | Obs | Value | Obs |
| 25000 | 6 | 2000000 | 3 |
| 150000 | 12 | 3000000 | 4 |
| 180000 | 11 | 6000000 | 9 |
| 240000 | 7 | 20000000 | 1 |
| 500000 | 10 | 70000000 | 2 |
The UNIVARIATE Procedure
6.PROC SGPLOT – VISUALIZATION
proc sgplot data=historical_wars;
vbar War_Name / response=Casualties datalabel;
xaxis display=(nolabel);
yaxis label="Number of Casualties";
run;
OUTPUT:
7.MACRO – WAR IMPACT CLASSIFICATION
%macro impact_classification;
data war_impact;
set historical_wars;
length Impact_Level $15;
if Casualties >= 20000000 then Impact_Level = 'Very Severe';
else if Casualties >= 5000000 then Impact_Level = 'Severe';
else if Casualties >= 1000000 then Impact_Level = 'Moderate';
else Impact_Level = 'Low';
run;
proc print data=war_impact;
run;
%mend;
%impact_classification;
OUTPUT:
| Obs | War_Name | Outcome | Start_Date | End_Date | Countries_Involved | Casualties | Year | Duration_Days | Impact_Level |
|---|---|---|---|---|---|---|---|---|---|
| 1 | World_War_I | Allied_Victory | 28JUL1914 | 11NOV1918 | 30 | 20000000 | 1914 | 1567 | Very Severe |
| 2 | World_War_II | Allied_Victory | 01SEP1939 | 02SEP1945 | 50 | 70000000 | 1939 | 2193 | Very Severe |
| 3 | Cold_War | Ideological_End | 12MAR1947 | 26DEC1991 | 45 | 2000000 | 1947 | 16360 | Moderate |
| 4 | Vietnam_War | Communist_Victory | 01NOV1955 | 30APR1975 | 10 | 3000000 | 1955 | 7120 | Moderate |
| 5 | Korean_War | Armistice | 25JUN1950 | 27JUL1953 | 20 | 1500000 | 1950 | 1128 | Moderate |
| 6 | Gulf_War | Coalition_Victory | 02AUG1990 | 28FEB1991 | 35 | 25000 | 1990 | 210 | Low |
| 7 | Afghan_War_US | Taliban_Victory | 07OCT2001 | 30AUG2021 | 40 | 240000 | 2001 | 7267 | Low |
| 8 | Iran_Iraq_War | Stalemate | 22SEP1980 | 20AUG1988 | 2 | 1000000 | 1980 | 2889 | Moderate |
| 9 | Napoleonic_Wars | Coalition_Victory | 18MAY1803 | 20NOV1815 | 25 | 6000000 | 1803 | 4569 | Severe |
| 10 | Crimean_War | Allied_Victory | 16OCT1853 | 30MAR1856 | 6 | 500000 | 1853 | 896 | Low |
| 11 | Franco_Prussian | German_Victory | 19JUL1870 | 28JAN1871 | 2 | 180000 | 1870 | 193 | Low |
| 12 | Russo_Japanese | Japanese_Victory | 08FEB1904 | 05SEP1905 | 2 | 150000 | 1904 | 575 | Low |
8.DATE FUNCTION (INTCK)
data war_years;
set historical_wars;
Duration_Years = intck('year', Start_Date, End_Date);
run;
proc print data=war_years;
run;
OUTPUT:
| Obs | War_Name | Outcome | Start_Date | End_Date | Countries_Involved | Casualties | Year | Duration_Days | Duration_Years |
|---|---|---|---|---|---|---|---|---|---|
| 1 | World_War_I | Allied_Victory | 28JUL1914 | 11NOV1918 | 30 | 20000000 | 1914 | 1567 | 4 |
| 2 | World_War_II | Allied_Victory | 01SEP1939 | 02SEP1945 | 50 | 70000000 | 1939 | 2193 | 6 |
| 3 | Cold_War | Ideological_End | 12MAR1947 | 26DEC1991 | 45 | 2000000 | 1947 | 16360 | 44 |
| 4 | Vietnam_War | Communist_Victory | 01NOV1955 | 30APR1975 | 10 | 3000000 | 1955 | 7120 | 20 |
| 5 | Korean_War | Armistice | 25JUN1950 | 27JUL1953 | 20 | 1500000 | 1950 | 1128 | 3 |
| 6 | Gulf_War | Coalition_Victory | 02AUG1990 | 28FEB1991 | 35 | 25000 | 1990 | 210 | 1 |
| 7 | Afghan_War_US | Taliban_Victory | 07OCT2001 | 30AUG2021 | 40 | 240000 | 2001 | 7267 | 20 |
| 8 | Iran_Iraq_War | Stalemate | 22SEP1980 | 20AUG1988 | 2 | 1000000 | 1980 | 2889 | 8 |
| 9 | Napoleonic_Wars | Coalition_Victory | 18MAY1803 | 20NOV1815 | 25 | 6000000 | 1803 | 4569 | 12 |
| 10 | Crimean_War | Allied_Victory | 16OCT1853 | 30MAR1856 | 6 | 500000 | 1853 | 896 | 3 |
| 11 | Franco_Prussian | German_Victory | 19JUL1870 | 28JAN1871 | 2 | 180000 | 1870 | 193 | 1 |
| 12 | Russo_Japanese | Japanese_Victory | 08FEB1904 | 05SEP1905 | 2 | 150000 | 1904 | 575 | 1 |
9.ADDITIONAL PROC – PROC PRINT (DATA REVIEW)
proc print data=war_impact(obs=5);
title "Sample Output with Impact Classification";
run;
OUTPUT:
| Obs | War_Name | Outcome | Start_Date | End_Date | Countries_Involved | Casualties | Year | Duration_Days | Impact_Level |
|---|---|---|---|---|---|---|---|---|---|
| 1 | World_War_I | Allied_Victory | 28JUL1914 | 11NOV1918 | 30 | 20000000 | 1914 | 1567 | Very Severe |
| 2 | World_War_II | Allied_Victory | 01SEP1939 | 02SEP1945 | 50 | 70000000 | 1939 | 2193 | Very Severe |
| 3 | Cold_War | Ideological_End | 12MAR1947 | 26DEC1991 | 45 | 2000000 | 1947 | 16360 | Moderate |
| 4 | Vietnam_War | Communist_Victory | 01NOV1955 | 30APR1975 | 10 | 3000000 | 1955 | 7120 | Moderate |
| 5 | Korean_War | Armistice | 25JUN1950 | 27JUL1953 | 20 | 1500000 | 1950 | 1128 | Moderate |
10.PIE PLOT – DISTRIBUTION OF WAR OUTCOMES
proc gchart data=historical_wars;
pie Outcome / percent=inside value=inside;
title "DISTRIBUTION OF WAR OUTCOMES USING PIE CHART";
run;
quit;
To Visit My Previous Online Streaming Flatform Dataset:Click Here
To Visit My Previous Statistical Evaluation Of Clinical Trials:Click Here
To Visit My Previous Unlocking Retail Insights Dataset:Click Here
To Visit My Previous Sas Interview Questions-1:Click Here
Follow Us On :
--- FOLLOW OUR BLOG FOR MORE INFORMATION.
--->PLEASE DO COMMENTS AND SHARE OUR BLOG.
No comments:
Post a Comment