* Required macros: 'regr', 'diff'; * this SAS code shows how to do calculations for regression estimators using SAS as a calculator. Note that there are other ways to use SAS, like Proc REG to perform these calculations directly; data ex6_9 ; input student achieve final @@ ; cards ; 1 39 65 2 43 78 3 21 52 4 64 82 5 57 92 6 47 89 7 28 73 8 75 98 9 34 56 10 52 75 ; run; proc sgplot ; scatter x=achieve y=final; run ; proc means ; var final achieve; run; data regcalc ; set ex6_9 ; bnumerator = (achieve -46)*(final -76) ; bdenominator = (achieve -46)**2 ; run; proc means sum data = regcalc ; var bnumerator bdenominator ; run ; data msecalc ; set ex6_9 ; finalhat = 76 + .7656*(achieve -46) ; sqerror = (final -finalhat)**2 ; run; proc means sum data = msecalc ; var sqerror ; run ; * Using PROC REG proc reg plots=(diagnostics residuals) data = ex6_9 ; model final = achieve ; run; * Using SAS as a calculator for the difference estimator; data ex6_10 ; input sample auditvalue bookvalue @@ ; d = auditvalue -bookvalue ; cards ; 1 9 10 2 14 12 3 7 8 4 29 26 5 45 47 6 109 112 7 40 36 8 238 240 9 60 59 10 170 167 ; run; proc splot data = ex6_10 ; scatter x=bookvalue y=auditvalue; run; proc means data = ex6_10 ; var auditvalue bookvalue ; run ; data msecalc6_10; set ex6_10 ; sqerror = (d - .4)**2; run; proc means sum data = msecalc6_10 ; var sqerror ; run ; * Make sure you have run the required macros; %regr(sample=ex6_9,npop=488,response=final,param=mean,x=achieve,mu_x=52) ; %diff(sample=ex6_10,npop=180,response=auditvalue,param=mean,x=bookvalue,mu_x=74) ;