/*Kaz's SAS juku*/ /*www.estat.us*/ /*PROC MEANS*/ Data ABC; set sashelp.Prdsale; /*This is a SAS default data set for a practice*/ run; /*PROC MEANS*/ /*the most basic*/ proc means data=ABC; var ACTUAL PREDICT; run; /*Get group means*/ proc means data=ABC; class PRODUCT; var ACTUAL PREDICT; run; /*Get various statistics*/ proc means data=ABC mean max min n stderr median ; var ACTUAL PREDICT; run; /*Using ODS (Output Delivery System) save statistical results in a SAS data set*/ proc means data=ABC mean max min n stderr median ; var ACTUAL PREDICT; ods output summary=result_in_here; run; proc print data=result_in_here; run; /*Suppress ugly default printing and use ODS*/ ods listing close; proc means data=ABC ; var ACTUAL PREDICT; ods output summary=result_in_here; run; ods listing; proc print data=result_in_here; run; /*Using data steps, manipulate the result data set in a way that is easy to understand when printed. And save the result in an excel sheet*/ ods listing close; proc means data=ABC ; class PRODUCT; var ACTUAL PREDICT; ods output summary=result_in_here; run; ods listing; data result_in_here; /*it is okay to use the same name. It just gets updated.*/ set result_in_here; /*substracting predicted sales from actual sales*/ Difference=ACTUAL_MEAN-PREDICT_MEAN; if Difference > 0 then COMMENT="Congratulation! You achieved higher than prediction"; if Difference < 0 then COMMENT="Try Again. You did not perform as expected"; run; proc print round noobs data=result_in_here; title "Sales: did we achieve our goal?"; var PRODUCT ACTUAL_mean PREDICT_mean COMMENT; run; /*saving result in Excel sheet in C-drive, temp directory*/ PROC EXPORT DATA= result_in_here OUTFILE= "c:/temp/result_in_here.xls" DBMS=EXCEL2000 REPLACE; RUN;