/*Kaz's SAS juku course*/ /*www.estat.us*/ /*PROC FREQ*/ Data ABC; set sashelp.Class; /*This is a SAS default data set for a practice*/ run; /*get frequency, most basic*/ proc freq data=ABC; tables SEX AGE; run; /*get cross tab*/ proc freq data=ABC; tables SEX*AGE; run; /*get frequency by subgroups*/ proc sort data=ABC out=ABC;by AGE;run; proc freq data=ABC; by AGE; tables SEX; run; /*Supress default printing, use ODS (Output Delivery System), and get Excel output*/ ods listing close; proc freq data=ABC; tables SEX; ods output OneWayFreqs=freq_result_in_here; run; ods listing; proc print data=freq_result_in_here; run; /*saving result in Excel sheet in C-drive, temp directory*/ PROC EXPORT DATA= freq_result_in_here OUTFILE= "c:/temp/freq_result_in_here.xls" DBMS=EXCEL2000 REPLACE; RUN;