Chapter Contents

Previous

Next
Statements with the Same Function in Multiple Procedures

FREQ


Treats observations as if they appear multiple times in the input data set.

Tip: You can use a WEIGHT statement and a FREQ statement in the same step of any procedure that supports both statements.


FREQ variable;


Required Arguments

variable
specifies a numeric variable whose value represents the frequency of the observation. If you use the FREQ statement, the procedure assumes that each observation represents n observations, where n is the value of variable. If variable is not an integer, the SAS System truncates it. If variable is less than 1 or is missing, the procedure does not use that observation to calculate statistics. If a FREQ statement does not appear, each observation has a default frequency of 1.

The sum of the frequency variable represents the total number of observations.


Procedures That Support the FREQ Statement

Note:   PROC FORMS does not calculate statistics. In PROC FORMS, the value of the frequency variable affects the number of form units that are printed for each observation.  [cautionend]


Example
The data in this example represent a ship's course and the speed (in knots), recorded every hour. The frequency variable, Hours, represents the number of hours that the ship maintained the same course and speed. Each of the following PROC MEANS steps calculates average course and speed. The different results demonstrate the effect of using Hours as a frequency variable.

The following PROC MEANS step does not use a frequency variable:

options nodate pageno=1 linesize=64 pagesize=40;

data track;
   input Course Speed Hours @@;
   datalines;
30  4  8 50 7 20
75 10 30 30 8 10
80  9 22 20 8 25
83 11  6 20 6 20
;
proc means data=track maxdec=2 n mean;
   var course speed;
   title 'Average Course and Speed';
run;
Without a frequency variable, each observation has a frequency of 1, and the total number of observations is 8. [HTML Output]  [Listing Output]

The second PROC MEANS step uses Hours as a frequency variable:

   proc means data=track maxdec=2 n mean;
      var course speed;
      freq hours;
      title 'Average Course and Speed';
   run;
When you use Hours as a frequency variable, the frequency of each observation is the value of Hours, and the total number of observations is 141 (the sum of the values of the frequency variable). [HTML Output]  [Listing Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.