simple

freq

Description

Generates a frequency distribution for one or more variables. It calculates counts, percentages, cumulative counts, and cumulative percentages for the unique values of the specified input variables. This action is fundamental for summarizing categorical data and understanding value distributions.

Settings
ParameterDescription
tableSpecifies the input table name, library, and optional settings such as group-by variables, computed variables, and filtering (where clause).
inputsSpecifies the list of variables to analyze. If not specified, all numeric and character variables are analyzed.
casOutSpecifies the output table where the frequency results will be stored. Includes options for compression, replication, and memory format.
includeMissingWhen set to True, missing values are treated as a valid level and included in the frequency counts and percentage calculations.
descendingWhen set to True, sorts the levels of the variables (and group-by variables) in descending order.
rawWhen set to True, uses the raw unformatted values of the variables for analysis rather than formatted values.
groupByLimitSets a limit on the number of unique group-by keys. If the limit is exceeded, the action stops to prevent excessive output size.
writePartOnTheFlyWhen set to True, writes results to the output table immediately after processing each BY-group, useful for very large tasks.
Data Preparation View data prep sheet
Load Sample Data

Loads the 'cars' dataset from the SASHELP library into the 'casuser' CAS library for analysis.

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

Examples

Calculates the frequency distribution for the 'Type' variable (e.g., SUV, Sedan) in the cars table.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3SIMPLE.freq / TABLE={name="cars", caslib="casuser"} inputs={"Type"};
4 
5RUN;
6 

Calculates frequencies for the 'Origin' variable, grouped by car 'Type'. Missing values are included, and the results are saved to a CAS table named 'freq_results'.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3SIMPLE.freq / TABLE={name="cars", caslib="casuser", groupBy={"Type"}} inputs={"Origin"} includeMissing=true casOut={name="freq_results", caslib="casuser", replace=true};
4 
5RUN;
6 

FAQ

What is the primary function of the freq action?
How can I save the results of the frequency analysis to a CAS table?
How can I include missing values in the frequency calculation?
Is it possible to use raw values instead of formatted values for the analysis?
How can I control the sort order of group-by variables?
What is the purpose of the "groupByLimit" parameter?
How can I specify variable attributes such as labels or formats for the analysis?
What does the "writePartOnTheFly" parameter do?