/**t Confidence Interval for the Mean **/ /*********************************************************** Macro tint1 does 1 sample t confidence interval for the Mean. INPUT: dataset: input data set variable: variable to be analyzed level: confidence level OUTPUT: sample mean and confidence interval ***********************************************************/ %macro tint1(dataset,variable,level); proc summary data=&dataset; var &variable; output out=SummaryStats n=n mean=PointEstimate std=StdDev; run; data ci; set SummaryStats; ConfLevel=&level; df=n-1; Q=(1+ConfLevel)/2; T_Quantile=tinv(Q,df); StdErrEstimate=StdDev/sqrt(n); LowerConfLimit=PointEstimate-T_Quantile*StdErrEstimate; UpperConfLimit=PointEstimate+T_Quantile*StdErrEstimate; keep ConfLevel df PointEstimate StdErrEstimate LowerConfLimit UpperConfLimit; run; proc print noobs;run; %mend tint1; /*********************************************************** Sample call: data ldl; input decrease_ldl @@; cards; -7.6 13.9 27.1 14.8 6.3 42.0 41.7 18.5 31.2 24.0 ; run; %tint1(ldl,decrease_ldl,.95); ***********************************************************/