options pagesize=150 linesize=64;
filename grafout 'g01.ps';
goptions device=PSLCMYK gsfname=grafout 
   rotate=landscape gsfmode=append;
/* Mark.B: Simulate data from various                 */
/* distributions and show size for normal theory test.*/
%include "common.sas";
title1 'Sizes (Type I error rates) for 1-sample T tests';
%test1(10,10000,0); proc print data=size noobs; run;
%test1(40,10000,0); proc print data=size noobs; run;
/* Mark.D: Arsenic Example. */;
/* Data from http://lib.stat.cmu.edu/datasets/Arsenic         */
/* reformatted into ASCII on the course home page.  Data re-  */
/* flect arsenic levels in toenail clippings; covariates in-  */
/* clude age, sex (1=M), categorical measures of quantities   */
/* used for drinking and cooking, arsenic in the water, and   */
/* arsenic in the nails.  To make arsenic.dat from Arsenic, do*/
/*antiword Arsenic|awk '((NR>39)&&(NR<61)){print}'>arsenic.dat*/
/* Potential threshold for ill health effects for toenails is */
/* .26 http://www.efsa.europa.eu/de/scdocs/doc/1351.pdf       */
data arsenic; infile 'arsenic.dat'; 
   input age sex drink cook arswater arsnails; run;
*SAS proc univeriate reports the statistic number exceeding;
*.26-number lower than .26, all divided by two, and only does ;
* 2-sided testing, which is not really what I want.;  
proc univariate data=arsenic mu0=.26 ciquantdf(alpha=.05); 
   var arsnails; run;
title1 'Sign Test';
proc print data=signtestout noobs; run;
title1 'Basic Intervals';
*SAS proc univariate gives confidence intervals associated with;
*the sign test.  You could show these graphically with the;
*cdfplot statement in version 9.3, or lifetest will plot 1-cdf;
*and confidence bands.;
data bio; set bio; 
   keep Quantile Estimate LCLDistFree UCLDistFree; run;
* To get just the median add the line;
* if Quantile ne "50% Median" then delete;
proc print data=bio noobs; run;
* You can do associated binomial test instead of sign test.;
data arsenic; set arsenic;y=arsnails>.26; run;
proc freq data=arsenic; tables y/binomial(p=.5 level=1);
   exact binomial; run;