* Sample SAS Program "procfreq.sas" ; /* DESCRIPTIVE STATISTICS: */ /* Producing FREQuency Tables */ /* - Ommiting cumulative Stats */ /* Producing Crosstabulations */ /* - Ommiting column and row percentages */ /* Producing N-Way Tables */ /* Selecting observations with PROC FREQ */ /* (See note 1 below.) */ /* GLOBAL STATEMENTS */ libname sas3 '[drive]:\[your_folder\]'; options ls=75; title; footnote; /* PRODUCING FREQUENCY TABLES */ proc freq data=sas3.htwt2; tables age; run; /* PRODUCING FREQUENCY TABLES */ /* OMITTING CUMULATIVE STATS */ proc freq data=sas3.htwt2; tables age / nocum; run; /* PRODUCING CROSSTABS */ proc freq data=sas3.htwt2; tables sex*age; run; /* PRODUCING CROSSTABS */ /* OMITTING COLUMN AND ROW PERCENTAGES */ proc freq data=sas3.htwt2; tables sex*age / nocol norow; run; /* CREATING N-WAY TABLES */ proc freq data=sas3.htwt2; tables sex*age*height / nocol norow; run; /* COMBINING DATA AND PROC STEPS */ data temp; set sas3.htwt2; if height<74 then height2='average'; else height2='tall'; if age<40 then age2='group1'; else age2='group2'; run; proc freq data=temp; tables sex*age2*height2; run; /* SELECTING OBSERVATIONS WITH PROC FREQ */ proc freq data=sas3.htwt2; where sex='F'; tables height*weight / nocol norow; footnote 'Females Only'; run; /* SELECTING OBSERVATIONS WITH PROC FREQ */ /* USING TEMP DATA SET FROM EARLIER DATA STEP */ proc freq data=temp; where sex='M'; tables height2*age2; title 'Males Only'; footnote; run; /*-----------------------------------------------*/ /* NOTES: */ /* 1. SAS provides a number of procedures for */ /* generating descriptive statistics for */ /* SAS Data Sets, including Proc Tabulate, */ /* Proc Means, Proc Summary and Proc Freq. */ /* Each of these procedures produces some */ /* of the same statistics, while each has */ /* its own unique options as well as its */ /* own style of output. For more */ /* information on each of these procedures */ /* refer to the SAS Procedures Guide, */ /* Version 6. */ /*-----------------------------------------------*/