/**Normal Confidence Interval for the Mean Assuming Known Population Standard Deviation**/ /*********************************************************** Macro nint1 computes 1 sample normal confidence interval for the Mean. INPUT: dataset: input data set variable: variable to be analyzed sigma: population standard deviation level: confidence level OUTPUT: sample mean and confidence interval ***********************************************************/ %macro nint1(dataset,variable,sigma,level); %let alpha2=%sysevalf((1+&level)/2); %let sig=%sysevalf(&sigma); proc summary data=&dataset; var &variable; output out=z_out n=n mean=mean; run; data z_out; set z_out; zquant=probit(&alpha2); moe=&sig/sqrt(n); LCL=mean-zquant*moe; UCL=mean+zquant*moe; run; proc print noobs; var mean LCL UCL; run; %mend nint1; /*********************************************************** Sample call: First submit the above macro code, then the code below. This first part reads in the LDL data from class. ***********************************************************/ 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; /*********************************************************** And this is how the macro is called to get a 95% confidence interval assuming the population standard deviation is 16. ***********************************************************/ %nint1(ldl,decrease_ldl,16.,.95);