freqTab

freqTab

Description

The freqTab action in the Frequency and Crosstabulation Analysis action set constructs frequency and crosstabulation tables. It functions similarly to the FREQ procedure in SAS, allowing users to produce one-way to n-way frequency and contingency tables. It provides counts, percentages, and cumulative statistics, and supports options for handling missing values, weighting, and ordering results.

Settings
ParameterDescription
tableSpecifies the input table settings, including the table name and CAS library.
tabulateSpecifies the variables for the analysis. Use the 'vars' subparameter for the primary variables and 'cross' for variables to crosstabulate against.
weightSpecifies a numeric variable to use as a weight for each observation.
orderDetermines the sort order of the variable levels: 'FORMATTED' (default), 'FREQ' (by descending count), or 'INTERNAL' (unformatted value).
descendingIf set to True, reverses the sort order specified by the 'order' parameter.
includeMissingIf set to True, missing values are treated as a valid level in the frequency tables.
outputTablesLists the names of the result tables to save to the server.
tabDisplayControls the format of the output tables, such as using 'CROSSLIST' or 'LIST' format for crosstabulations.
Data Preparation View data prep sheet
Load Sample Data

Loads the 'cars' dataset from the SAS help library into the CAS session.

Copied!
1DATA casuser.cars; SET sashelp.cars; RUN;

Examples

Calculates the frequency distribution for the 'Type' variable in the cars table.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3freqTab.freqTab / TABLE={name="cars"} tabulate={{vars={"Type"}}};
4 
5RUN;
6 
Result :
A table displaying the Frequency, Percent, Cumulative Frequency, and Cumulative Percent for each car Type (e.g., Sedan, SUV, Sports).

Produces a crosstabulation of 'Origin' by 'Type', sorting results by frequency descending, including missing values, and weighing by 'Invoice'.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3freqTab.freqTab / TABLE={name="cars"} weight="Invoice" order="FREQ" includeMissing=true tabulate={{vars={"Origin"}, cross={"Type"}}} tabDisplay={FORMAT="CROSSLIST"};
4 
5RUN;
6 
Result :
A crosstabulation table of Car Origin vs. Type. Levels appear in descending order of frequency. Missing values are included as distinct levels. Counts are weighted by the Invoice amount.

FAQ

What is the purpose of the freqTab action?
Which parameter is required to specify the input data for the freqTab action?
How can I reverse the sort order of the variable levels in the results?
How do I include missing values as valid levels in the analysis?
Can I include observations with zero weights in the analysis?
How can I specify the sort order for the levels of the variables?
How do I define the frequency or crosstabulation tables to be produced?
What parameter is used to save the results as CAS tables on the server?
How can I apply weights to the observations?
What options are available to control the display format of crosstabulation tables?
How can I limit the number of variable levels displayed in the variable level information table?
Is it possible to suppress the analysis if the number of BY groups is too large?