Published on :
Data Analysis CREATION_INTERNE

Creating a Frequency Table

This code is also available in: Deutsch Español Français
Awaiting validation
The example proceeds in two steps. First, a DATA step is used to create a new table `mycaslib.qualifyapps` based on an existing table `mycaslib.creditqualify`. A new variable `Count` is added, taking the value 0 if 'Credit_Qualification' is 'N/A' and 1 otherwise. Second, the `freqTab.freqTab` action of PROC CAS is employed to generate a frequency table for the 'Credit_Qualification' variable, using the 'Count' variable as a weight. This allows determining the percentage of people qualified for credit.
Data Analysis

Type : CREATION_INTERNE


The examples use data (mycaslib.creditqualify) that is assumed to exist in the CAS library 'mycaslib'. The first step creates a new table (mycaslib.qualifyapps) from it, to be used in the second step. To make the example self-contained, the 'mycaslib.creditqualify' table should be created or be a SASHELP dataset.

1 Code Block
DATA STEP Data
Explanation :
This DATA step code creates a new table named `mycaslib.qualifyapps`. It reads data from `mycaslib.creditqualify` and adds a `Count` variable. If 'Credit_Qualification' is 'N/A', `Count` is set to 0; otherwise, `Count` is set to 1.
Copied!
1DATA mycaslib.qualifyapps;
2 SET mycaslib.creditqualify;
3 IF Credit_Qualification='N/A' THEN Count=0;
4 ELSE Count=1;
5RUN;
2 Code Block
PROC CAS
Explanation :
This section uses the `freqTab.freqTab` action of PROC CAS to generate a frequency table. It takes the `qualifyapps` table created previously, uses the `Count` variable as a weight, and calculates frequencies for the `Credit_Qualification` variable. This allows obtaining the distribution of credit qualifications.
Copied!
1PROC CAS;
2 ACTION freqTab.freqTab/
3 TABLE='qualifyapps',
4 weight='Count',
5 tabulate={'Credit_Qualification'};
6QUIT;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Copyright © SAS Institute Inc. All Rights Reserved