• <Helps for GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Array Object
      • Audio Object
      • Barcode
      • File Object
      • Freq Object
      • HashMap Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
        • EndCase Statement
        • Export Statement
        • Freq Statement (Unnamed)
        • GetDeck Function
        • PutDeck Function
        • Set Behavior Export Statement
        • SetOutput Function
        • Skip Case Statement
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
    • Templated Reporting System
    • Appendix
  • <Helps for CSEntry>
  • <Helps for CSBatch>
  • <Helps for CSTab>
  • <Helps for DataViewer>
  • <Helps for TextView>
  • <Helps for TblView>
  • <Helps for TRSWin>
  • <Helps for CSDeploy>
  • <Helps for CSPack>
  • <Helps for CSFreq>
  • <Helps for CSSort>
  • <Helps for CSExport>
  • <Helps for CSReFmt>
  • <Helps for CSDiff>
  • <Helps for CSConcat>
  • <Helps for TRSSetup>
  • <Helps for ParadataViewer>
  • <Helps for ParadataConcat>
  • <Helps for CSIndex>
  • <Helps for Excel2CSPro>
  • <Helps for CSWeb>

Freq Statement (Unnamed)

Format
freq
include
(variables_to_tabulate)
『exclude(variables_not_to_tabulate)』
『disjoint』
『breakdown(length)』
『universe(condition)』
『weight(weight_value)』
『formatting_options』
;
Description
The freq statement is used to define a frequency table that will be written to the frequencies file. Unlike named frequencies, which allow for control over when frequencies are tallied, frequencies generated using the freq statement are tallied at the location where they are defined. Due to this, the statement cannot be located in PROC GLOBAL, in user-defined functions, or in application procedures.
The Tabulate Frequencies tool generates freq statements automatically, so one way to learn about how to use the statement is to select items to tabulate in that tool and then use the View -> Batch Logic option to see the commands used to generate the specified frequencies.
Specifying Variables to Tabulate
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:
include(PERSON_REC)
exclude(P25_RELIGION, P26_TRIBE)
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:
FlagInclude/Exclude All...
numericnumeric items
floatnumeric items with decimals
integernumeric items without decimals
longnumeric items without decimals and length 3 - 15
shortnumeric items without decimals and length 1 - 2
alphaalphanumeric items
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).
include(numeric, alpha, PERSON_REC)
Leaving the include list empty is as if you coded the primary dictionary name. For example:
include()
// may be translated to:
include(CENSUS_DICT)
If you do not need to exclude any variables, the include command is optional. For example, these unnamed frequency statements are the same:
freq include(P03_SEX);
freq(P03_SEX);
Handling Variable Occurrences
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:
freq include(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):
freq include(P03_SEX)
     
disjoint;
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)
     
exclude(P03_SEX(1), P03_SEX(2))
     
disjoint;
Alphanumeric Breakdown
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)
Additional Commands
The optional command universe allows you to specify a condition under which the frequency should be tallied. The values will be tallied when the condition evaluates to true.
The optional command weight allows you to weight each tally. The weight_value can be a constant number (like 10), a dictionary item (like HH_WEIGHT) or any other numeric expression. If no weight is provided, a weight of 1 is used during the tallying.
Optional formatting options allow you to control how the frequency tables are generated. The formatting options include the following commands: valueset, distinct, vset, heading, stat, percentiles, nofreq, decimals, sort, nonetpercents, and pagelength.
Example 1
PROC QUEST

    // create frequency tables for all numeric items in the
    // HOUSING_REC record with the exception of H13_PERSONS

   
freq
    include
(numeric, HOUSING_REC)
   
exclude(H13_PERSONS);
Example 2
PROC QUEST

    // create frequency tables for the default selection of items in
    // the PERSON_REC record, tallying only the first record occurrence

    // universe is used to make sure that we do not tally empty households

    // weight is 20 because we are creating frequencies on a 5% sample file

    // distinct means that the frequency tables will show all values,
    // not combining values if the value sets have ranges (such as age 0-4)

   
freq
    include
(PERSON_REC(1))
   
universe(totocc(PERSON_REC) > 0)
   
weight(20)
    distinct;
Example 3
PROC QUEST

    // create a frequency table for the item H15_ASSETS, which
    // was collected using a checkbox with each value of length 2

   
freq(H15_ASSETS)
    breakdown(
2);
See also: Freq Object, Freq Statement (Named), Frequency Formatting Options