statement creates a freq
object with the name freq_name
. The freq name must be unique and must contain only letters, numbers, or the underscore character. The name must begin with a letter. You can declare freqs globally in PROC GLOBAL
or locally in functions or procedures.
Freq objects are similar to unnamed frequencies
except that you control when they are tallied (using the freq.tally
function). Because of this, the universe
commands, which are part of the unnamed frequencies specification, are not available. You can control the universe (using an if
statement) and you can control the weight by passing an argument to the freq.tally
The include command is used to specify what variables should be tabulated. At least one frequency table will be created for every variable specified in the include list. The variables_to_tabulate is a list of variables, separated by commas, that can include:
- Dictionary names: dictionaries, records, and items
- Form names: forms, groups, and blocks
- Logic names: numeric and string variables
The optional exclude command is used to specify variables that should be removed from the inclusion list. The variables_not_to_tabulate is a list of variables as defined above. The exclude command is particularly useful when including records. For example, if you want to tabulate most items on a record with a couple exceptions, you might code:
When including or excluding a name that may contain more than one variable—dictionaries, records, forms, groups, and blocks—CSPro uses a rule to determine whether items contained in that grouping should be included in the list of variables to tabulate:
Default rule: Include the item if it has a value set; if no value set is defined, then include the item if it has length 1 - 4.
You can override the default selection by adding one or more of these flags to the include/exclude list:
|float||numeric items with decimals|
|integer||numeric items without decimals|
|long||numeric items without decimals and length 3 - 15|
|short||numeric items without decimals and length 1 - 2|
These six flags will never include items that have subitems. You can use a combination of flags; for example, this would include all items from PERSON_REC with the exception of items that have subitems (though the subitems would be included).
Leaving the include list empty is as if you coded the primary dictionary name. For example:
// may be translated to:
If you do not need to exclude any variables, the include command is optional. For example, these unnamed frequency statements are the same:
By default, when frequencies are tallied for a multiply-occurring item, all of the occurrences of the item are tallied. For example, assuming that P03_SEX is on a record with 50 occurrences, coding this will tally all defined occurrences of P03_SEX:
If the first house is vacant, then no sex values are tallied; if the second house has three people, then three sex values are tallied; and so on.
If you would like to tally a specific occurrence, you can specify the occurrence in the include/exclude list. For example, this would create two tables, one for all sex occurrences, and one for the head's sex (assuming that the head is the first occurrence):
freq include(P03_SEX, P03_SEX(1));
You can specify occurrence values when using items or records. PERSON_REC(1), for example, would create tables for the first occurrence of the items in PERSON_REC. If you specify an occurrence, the value will be tallied regardless of whether the occurrence exists. For example, while P03_SEX would not tally vacant households, P03_SEX(1) will include tallies of blank values for vacant households.
An optional command, disjoint, is a shortcut way of indicating that a frequency table should be created for every occurrence of a variable. For example, this code would create a table for each of the occurrences of P03_SEX, resulting in 50 tables (for occurrence 1, occurrence 2, and so on until occurrence 50):
When using disjoint, you can use (*) as an occurrence to specify that you would like to ignore the disjoint setting. For example, this code would create 49 tables (for the combined occurrences, for occurrence 3, occurrence 4, and so on until occurrence 50).
freq include(P03_SEX(*), P03_SEX)
The optional command breakdown allows you to control how alphanumeric items and string variables are tallied. A positive numeric constant, length, specifies a number used to split these values before tallying. This can be useful when creating frequencies for data collected using checkboxes. For example, assuming CHECKBOX_FIELD occurs twice, first as "AB" and then as "BC":
freq include(CHECKBOX_FIELD); // results in: "AB" (1)
// "BC" (1)
freq include(CHECKBOX_FIELD) // results in: "A" (1)
breakdown(1); // "B" (2)
// "C" (1)
Optional formatting options
allow you to control how the frequency tables are generated. The formatting options include the following commands: valueset
, and pagelength