************************************************************** * Program: 503EX1.SAS * * Description: one sample t-test for paired data * **************************************************************; Options center ls=75; title1 'EXERCISE NUMBER 1, STA 503'; ************************************************************** *The next paragraph creates a data set called ex1. This * *dataset has variables whose names are indicated in the INPUT* *statement. Those variables that followed by a $, are * *character variables. All others are numeric variables. * * * *All names must be less than 8 characters and must start with* *an alphabet. * * * *Any statement that is preceded by an * and succeeded by a * *semicolon is ignored as a comment. * * * *In SAS, a semicolon must end every statement. A statement * *can spill to several lines * **************************************************************; data ex1; input id sex $ drug placebo; diff = drug - placebo; cards; 1 M 19 22 2 M 11 18 3 F 14 17 4 F 17 19 5 F 23 22 6 M 11 12 7 F 15 14 8 F 19 11 9 M 11 19 10 M 8 7 ; run; proc print data = ex1; proc univariate data = ex1; var diff; run; proc ttest data = ex1; class sex; var drug; run; data temp1; set ex1(keep=placebo); if placebo ne .; rename placebo=result; group='P'; data temp2; set ex1(keep=drug); rename drug=result; group='D'; run; data new; set temp1 temp2; proc print data = new; proc ttest data = new; class group; var result; run; data two; infile '503 data a1'; input inst time status age sex phecog phkarno patkarno mealcal wtloss ; run; proc contents data=two; proc print data=two; data three; input fed$ teeth$ numb; cards; breast normal 143 breast malocc 2 bottle normal 128 bottle malocc 9 ; run; proc freq data=three; weight numb; tables fed * teeth / exact; run; tables fed * teeth / chisq; run; ******************************************************; ********Data from Armitage and Berry, Example 8.2*****; ******************************************************; data eight2; input subject trt time; cards; 6 2 9.8 6 2 10.1 6 2 9.8 6 3 9.9 6 3 9.5 6 3 10.0 6 4 11.3 6 4 10.7 6 4 10.7 7 2 9.2 7 2 8.6 7 2 9.2 7 3 9.1 7 3 9.1 7 3 9.4 7 4 10.3 7 4 10.7 7 4 10.2 8 2 8.4 8 2 7.9 8 2 8.0 8 3 8.6 8 3 8.0 8 3 8.0 8 4 9.8 8 4 10.1 8 4 10.1 ; run; proc glm; class subject trt; model time=trt; means trt/lsd; proc glm; class subject trt; model time=subject trt; means trt/lsd; run; proc glm; class subject trt; model time=subject trt subject*trt; run; **** example of logistic regression; data logreg; input y x1 x2; cards; 1 0.2 1.5 0 0.2 1.5 0 0.3 0.5 0 0.3 0.5 1 0.18 1.4 1 0.18 1.4 0 0.12 0.6 1 0.12 0.6 ; run; proc logistic descending data=logreg; class x1; model y= x1 x2; output out=lreg lower=CLOW upper=CHIGH difdev=DEVCHANG p=PRID; run; proc print data=lreg; run; proc catmod data=logreg; direct x2; model y=x1 x2; *****weight count; if for big data, repeated times as count; respose/out=predict; run; data small; input y x cen; cards; 15 2 0 13 3 1 9 1 1 19 3 1 12 2 1 ; proc phreg data=small; model y*cen(0)=x; test1: test x=0; run; proc lifetest data=small; time y*cen(0); strata x; run; proc npar1way wilcoxon data=small; class x; var y; exact; run;