options dlcreatedir;
proc options option=dlcreatedir ;
run;
filename File "/folders/myfolders/raw_files/Airplane_Crashes_and_Fatalities_Since_1908.csv" ;
libname Lib "/folders/myfolders/DataSet";
/*Fetching Data from external file*/
data Lib.Airplanes(label="DETAILS:Airplanes Crashes since 1908");
infile File missover dsd lrecl=32767 firstobs=2 dlm=',' ;
input Date mmddyy10. +1 Time:$10. Location:$100. Operator: $50.
Flight: $50. Route: $100. Plane_Type: $100. Registration: $20. cn_In:$20. Aboard
Fatalities Ground Summary: $1000. ;
format Date mmddyy10.;
/* Extracting Year, Month and Day from Date */
Year=year(Date);
/* Trimming route */
Route=trim(Route);
/* Calculating Survivors */
Survivor=Aboard-Fatalities;
/* Calculating Decade */
Decade=floor(Year/10)*10;
drop Date;
run;
/***** SORTING AIRPLANES DATASET IN ASCENDING ORDER ******/
proc sort data=Lib.Airplanes;
by Year;
run;
/*//-----------------------CASUALTIES--------------// */
/*
* QUESTION:1) YEAR WHICH HAD THE MEAN NUMBER OF CRASHES CLOSEST TO MEDIAN NUMBER OF
* CRASHES ?
*/
/************** YEARS ********************/
ods select none; *NO PRINT FOR LINE 41 STATEMENT;
proc tabulate data=Lib.Airplanes out=WORK.YearlyCrashes( rename=(N=Crash)) ;
class Year;
table Year,N;
run;
ods select all; * PRINT FOR LINE 46 STATEMENT ;
proc tabulate data=WORK.YearlyCrashes;
var Crash Year ;
table (Year*Mean=''*F=4.)(Crash='No. of plane Crashes'*Mean*F=4.)(Year*Median=''*F=4.)
(Crash='No. of plane Crashes'*Median*F=4.)/rts=20.;
title3 color=RED bold 'Year which had the Mean number of crashes closest to Median number of
crashes';
run;
/* QUESTION :2) WHICH YEAR HAD THE MAXIMUM STANDARD DEVIATION FROM THE MEAN COMPARED TO THE STANDARD
* DEVIATION FROM THE MEAN WHOLE DATASET?
*/
proc tabulate data=Lib.Airplanes out=Work.Std(rename= Fatalities_std=SYstd);
var Fatalities;
class Year;
tables (Year='' All='Overall'),Fatalities='Causalties'* Std='Standard Deviation'*F=5./box='Year';
run;
/***** calculating std(individual)>std(overall) *********/
data Work.stdfinal;
set Work.std;
retain std_001 Year_00 0;
if(SYstd > last.SYstd) then
do;
std_001=SYstd;
Year_001=Year;
end;
keep std_001 Year_001;
run;
/******** printing yearly standard deviation(s) > overall standard deviations*******/
proc tabulate data=work.stdfinal;
class Year_001;
var std_001;
tables Year_001='', std_001='highest Standard Deviation'*sum=''*F=3./box='Year';
title color=RED bold ' YEAR WHICH HAD THE MAXIMUM STANDARD DEVIATION FROM THE MEAN COMPARED TO THE STANDARD DEVIATION FROM THE MEAN WHOLE DATASET';
run;
... View more