/* */ OPTIONS pagesize=40 linesize =80 NOCENTER ; run; DATA storms; *Mac path...; INFILE "Macintosh HD:Courses:613(StatSoftware):storms.csv" delimiter = "," missover ; *Windows path...; *INFILE "C:/.../storms.csv" delimiter = "," missover ; INPUT YEAR N_STORMS N_CAT N_HS_HIT N_HR_1_9 N_HR_1_5 N_W1 N_W2 N_W3 N_W4 N_W5 N_H_HIT N_HR N_TS N_SS ; label N_STORMS = "No. storms in database"; label N_CAT = "No. with entry in <> category"; label N_HS_HIT = "No. Made landfall over US as trop_storm /hurricane"; label N_HR_1_9 = "No. where category > 0"; label N_HR_1_5 = "No. that hit U.S. as hurricane coded 1-5"; label N_W1 = "No. that hit US with strength 1"; label N_W2 = "No. that hit US with strength 2"; label N_W3 = "No. that hit US with strength 3"; label N_W4 = "No. that hit US with strength 4"; label N_W5 = "No. that hit US with strength 5"; label N_H_HIT = "No. that hit US with strength > 0"; label N_HR = "No. where Max intensity = HR = hurricane"; label N_TS = "No. where Tp = TS = tropical storm"; lable N_SS = "No. where Tp = SS = subtropical storm"; decade = 10*INT(YEAR/10); /* use built-in fn. to compute decade */ /* INT( ) returns integer portion of argument */ IF YEAR < 1900 then 19thcent = 1 ; /* e.g. create /alter a variable */ ELSE 19thcent = 0 ; /* e.g. create /alter a variable */ IF YEAR ne . ; /* put obsn. into dataset only if year is not missing */ /* NOTE: 2 uses of <> ... */ /* 1. IF(condition); obsn. included in dataset only if condn. is TRUE */ /* 2. IF(condition) THEN ... further statements(s) */ /* e.g. create /alter a variable */ RUN; Proc CONTENTS DATA= storms; RUN; TITLE "PROC MEANS -- CLASS statement subdivides observations "; Proc MEANS data = storms N MIN MAX MEAN SUM MAXDEC=1; CLASS decade; VAR N_HR_1_5; RUN; TITLE "Most PROCs can direct a copy of output to new SAS dataset ... "; Proc MEANS data = storms N MEAN SUM MAXDEC=1; CLASS decade; VAR N_HR_1_5; OUTPUT OUT = stats N = No_years MEAN = ave_yr SUM = total; RUN; TITLE "Print out the observations in new dataset "; PROC PRINT DATA = STATS; RUN; TITLE "PLOT the mean no. per decade versus decade in new dataset "; PROC PLOT DATA = STATS; PLOT Ave_yr * decade; RUN; TITLE "exclude the nineteenth century observations from PLOT "; PROC PLOT DATA = STATS; PLOT Ave_yr * decade; WHERE (decade >= 1900 ); RUN; TITLE "Plot number (rather than mean) per decade, and exclude 1990s "; PROC PLOT DATA = STATS; PLOT total * decade; WHERE (decade >= 1900 AND decade <=1980 ); RUN; TITLE "Variability in numbers over decades 1900s to 1980s "; PROC MEANS DATA = STATS MAXDEC=1; Var total ; WHERE (decade >= 1900 AND decade <=1980 ); RUN; TITLE "direct statistics for several variables to new SAS dataset ... "; Proc MEANS data = storms N MEAN SUM NOPRINT; CLASS decade; VAR N_HR_1_5 N_W1 - N_W5; OUTPUT OUT = stats MEAN = ave_15 ave_1 - ave_5 SUM = tot15 tot1 - tot5; PROC PRINT DATA = STATS ROUND; RUN;