Previous Page | Next Page

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, then the procedure assumes that each observation represents n observations, where n is the value of variable. If variable is not an integer, then SAS truncates it. If variable is less than 1 or is missing, then the procedure does not use that observation to calculate statistics. If a FREQ statement does not appear, then 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


Example

The data in this example represents a ship's course and speed (in nautical miles per hour), 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.

                    Average Course and Speed                   1

                      The MEANS Procedure

                 Variable    N            Mean
                 -----------------------------
                 Course      8           48.50
                 Speed       8            7.88
                 -----------------------------

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. The total number of observations is 141 (the sum of the values of the frequency variable).

                    Average Course and Speed                   1

                      The MEANS Procedure

            Variable               N            Mean
            ----------------------------------------
            Course               141           49.28
            Speed                141            8.06
            ----------------------------------------

Previous Page | Next Page | Top of Page