/* version 1 of spiders.sas */ OPTIONS LS=75 NODATe; DATA spiders; INPUT males females; CARDS; 5.2 8.25 4.7 9.8 5.7 6.1 5.65 9 5.75 9.5 4.7 9.95 4.8 10.8 6.2 9.3 5.5 6.3 5.95 8.3 5.75 5.9 5.95 6.6 5.4 8.75 5.65 8.35 5.9 7.05 7.5 7.05 5.2 7.55 6.2 7 5.85 8.7 7 8.3 6.45 8.45 6.35 8.1 5.85 7.8 5.75 8 6.1 7.95 6.55 7.55 6.95 9.1 6.8 8 6.35 7.5 5.8 9.6 ; RUN; PROC MEANS DATA=spiders noprint; VAR males females; OUTPUT OUT=stats mean=mbar fbar stderr=sem sef n=nm nf; RUN; DATA t_test; SET stats; tstat=(mbar-fbar)/sqrt(sem**2 + sef**2); pvalue=2*probt(-1*abs(tstat),nm+nf-2); RUN; PROC PRINT data=t_test; TITLE "T-test analysis using a datastep"; RUN; /* now, conduct t-test using PROC TTEST */ /* PROC TTEST requires a single response variable + a CLASS variable denoting the sex of the spider */ DATA tall_spiders; SET spiders; ARRAY lengths{2} males females; ARRAY sname{2} $ ("M","F"); DO i=1 TO 2; spid_length=lengths{i}; sex=sname{i}; OUTPUT; END; RUN; PROC PRINT; TITLE "dataset called tall_spiders is set up in required format"; RUN; PROC TTEST; CLASS sex; VAR spid_length; RUN;