WEIGHT BY var_name. WEIGHT OFF.
WEIGHT assigns cases varying weights,
changing the frequency distribution of the active dataset. Execution of
WEIGHT is delayed until data have been read.
If a variable name is specified,
WEIGHT causes the values of that
variable to be used as weighting factors for subsequent statistical
procedures. Use of keyword
BY is optional but recommended. Weighting
variables must be numeric. Scratch variables may not be used for
weighting (see Scratch Variables).
OFF is specified, subsequent statistical procedures weight all
A positive integer weighting factor w on a case yields the same statistical output as would replicating the case w times. A weighting factor of 0 is treated for statistical purposes as if the case did not exist in the input. Weighting values need not be integers, but negative and system-missing values for the weighting variable are interpreted as weighting factors of 0. User-missing values are not treated specially.
WEIGHT is specified after
TEMPORARY, it affects only
the next procedure (see TEMPORARY).
WEIGHT does not cause cases in the active dataset to be
replicated in memory.
One could define a dataset containing an inventory of stock items. It would be reasonable to use a string variable for a description of the item, and a numeric variable for the number in stock, like in Example 13.5.
data list notable list /item (a16) quantity (f8.0). begin data nuts 345 screws 10034 washers 32012 bolts 876 end data. echo 'Unweighted frequency table'. frequencies /variables = item /format=dfreq. weight by quantity. echo 'Weighted frequency table'. frequencies /variables = item /format=dfreq.
One analysis which most surely would be of interest is
the relative amounts or each item in stock.
However without setting a weight variable,
(see FREQUENCIES) does not tell us what we want to know, since
there is only one case for each stock item. Example 13.6 shows the
difference between the weighted and unweighted frequency tables.
Unweighted frequency table
Weighted frequency table