/* Read from inline data */ /* Data */ data raw0; input Laps $ Control Test @@; datalines; Baseline 50.1488 51.8912 Baseline 49.2472 50.684 Baseline 50.7082 51.9655 Baseline 49.6399 50.5968 Baseline 50.4372 51.8736 Baseline 50.2273 51.6166 Baseline 50.0606 50.895 Baseline 50.2046 50.9899 Baseline 50.4921 51.6013 Test 50.0354 49.4885 Test 50.3589 48.7868 Test 49.8446 48.3581 Test 50.8973 49.3284 Test 51.2444 50.2403 Test 55.9998 54.1003 Test 55.0668 53.7085 Baseline 50.1678 51.3997 Baseline 49.6908 50.983 Baseline 49.6244 50.5118 Baseline 47.5206 49.4935 Baseline 49.7272 50.1476 Baseline 46.9486 48.8342 Baseline 47.9234 48.9613 Baseline 48.7489 49.1496 Test 52.0332 50.0265 Test 51.3607 50.7168 Test 51.0776 50.1817 Test 50.861 49.3742 Test 50.5268 49.1016 Test 49.1427 48.6476 ; run; proc print data=raw0; run; /* Sort data by */ proc sort data=raw0 out=raw; by Laps; run; proc print data=raw; run; /* Read Data diretclty from an external file */ PROC IMPORT OUT= WORK.raw1 DATAFILE= "E:\FuelAdditive.xls" DBMS=EXCEL REPLACE; /* specify file type excel */ sheet="sheet1"; GETNAMES=yes; RUN; proc print data=raw1; run; /* Add a new variable to the existing data*/ data additive; /*new data name: additive*/ set raw; Ratio=Control/Test; run; proc sort data=additive; by Laps; run; /* Descriptive Statistics: Mean, mdian, Max, min*/ proc means data=additive; var Control Test; run; /* Group means in one table. Sort data first */ proc sort data=additive; by Laps; run; proc means data=additive; var Control Test; class Laps; /* 'by Laps;' leads to two separate tables */ run; /* ---- Histogram Plot ---- */ title 'Compare Histograms'; proc univariate data=additive noprint; class Laps; histogram Ratio / nrows=2; run; /* ---- Normality Check ---- */ title 'Normality Check'; proc univariate data=additive normal; by Laps; var Ratio; QQPlot / Normal(mu=est sigma=est); run; /* ---- Independent two-sample t-test ---- */ title '2-sample t-test'; proc ttest data=additive; class Laps; var Ratio; run; /* ---- Paire T-test ----*/ /* Compare Two Shoe Sole Material based on paired data (Xi, Yi)*/ title 'Paired Comparison (paired t-test)'; data sole; input MaterialA MaterialB @@; datalines; 13.2 14 8.2 8.8 10.9 11.2 14.3 14.2 10.7 11.8 6.6 6.4 9.5 9.8 10.8 11.3 8.8 9.3 13.3 13.6 ; run; proc ttest data=sole; paired MaterialA*MaterialB; run; /* ---- Proc Freq for categorical data ----*/ /* -- Chisquare Test for 2x2 Contingency Table -- */ data TwoWayCount; length performance $ 4 motivation $5; input performance motivation Count @@; datalines; high money 49 high satis 51 marg money 53 marg satis 47 ; proc sort TwoWayCount; by performance; run; proc freq data=TwoWayCount; tables performance * motivation / chisq ; weight Count; title 'Job Performance vs Job Motivation'; run;