Statistical SAS VIYA CAS

Weighted Data Analysis: How to Calculate Qualification Rates in SAS CA

This code is also available in: Deutsch Español Français
Difficulty Level
Beginner
Published on :
Simon

Expert Advice

Simon
Expert SAS et fondateur.

Performing frequency analysis in the Cloud Analytic Services (CAS) environment is significantly different from using traditional Base SAS procedures. By leveraging the freqTab action, you are executing calculations across a distributed, in-memory architecture.

Why Use freqTab.freqTab?
While you can still use PROC FREQ in the Compute Server, the freqTab action is the "native" way to handle frequency in Viya.

Scalability: It processes massive datasets by splitting the rows across all available worker nodes.

Speed: Because the data is already in memory, there is no I/O bottleneck.
The functional analysis proceeds in two steps. First, a DATA STEP is used to create a 'Count' variable based on credit qualification ('Credit_Qualification'). If the qualification is 'N/A', the counter is 0; otherwise, it is 1. This step prepares the data for counting. Second, the 'freqTab.freqTab' action of PROC CAS is used to generate a frequency table of the 'Credit_Qualification' variable, using the 'Count' variable as a weight. This allows determining the percentage of qualified individuals based on their qualification status.
Data Analysis

Type : CREATION_INTERNE


The examples use data generated via a DATA STEP with datalines to simulate the 'mycaslib.creditqualify' table.

1 Code Block
DATA STEP Data
Explanation :
This code block first creates an example data table named 'mycaslib.creditqualify' with CustomerID and Credit_Qualification variables. Then, it creates a new table 'mycaslib.qualifyapps' from 'mycaslib.creditqualify'. A new 'Count' variable is added: it takes the value 0 if 'Credit_Qualification' is 'N/A', and 1 otherwise. This prepares a numerical field for counting valid qualifications.
Copied!
1DATA mycaslib.creditqualify;
2 INFILE DATALINES;
3 INPUT CustomerID Credit_Qualification $;
4 DATALINES;
51 A
62 N/A
73 B
84 A
95 N/A
106 C
11;
12RUN;
13 
14DATA mycaslib.qualifyapps;
15 SET mycaslib.creditqualify;
16 IF Credit_Qualification='N/A' THEN Count=0;
17 ELSE Count=1;
18RUN;
2 Code Block
PROC CAS (action freqTab.freqTab)
Explanation :
This code block uses the CAS procedure to execute the 'freqTab.freqTab' action. This action generates a frequency table for the 'Credit_Qualification' variable from the previously created 'qualifyapps' table. The 'Count' variable is specified as a weight, which allows totaling the counts for each 'Credit_Qualification' category, thereby determining the percentage of credit-qualified individuals.
Copied!
1PROC CAS;
2 ACTION freqTab.freqTab/
3 TABLE='qualifyapps',
4 weight='Count',
5 tabulate={'Credit_Qualification'};
6QUIT;
Pro Tip
When working with weighted frequencies in a distributed environment, always ensure your data is properly loaded into CAS using a CASLIB. If you notice unexpected results, check the log to ensure your DATA step didn't "fall back" to the Compute Server, which can happen if you reference a local library instead of a CAS library.
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.

Related Documentation

Aucune documentation spécifique pour cette catégorie.