Friday, April 18, 2025

SAS Viya - developing Code and building Model

SAS Viya for a Customer Churn Prediction Model (a popular business case, especially in telecom and banking) πŸš€.


πŸ’‘ Interview-Ready Project Example: Customer Churn Prediction using SAS Viya

"In one of my recent projects, I built a predictive model to identify customers likely to churn, using SAS Viya’s Cloud Analytic Services (CAS). 

This allowed the business to focus retention campaigns on high-risk customers and reduce churn significantly."


⚙️ Step-by-Step Approach


1️⃣ Data Preparation in SAS Viya
Loaded the raw data into CAS and cleaned it for missing values, outliers, and inconsistent entries.


cas mySession; libname casuser cas; data casuser.churn_data_clean; set casuser.customer_data_raw; if missing(age) then age = median(age); if missing(income) then income = mean(income); run;

2️⃣ Exploratory Data Analysis (EDA)
Used PROC SGPLOT and Visual Analytics to identify customer churn patterns.


proc sgplot data=casuser.churn_data_clean; vbar plan_type / group=churn_event; run;

3️⃣ Model Building — Gradient Boosting (PROC GRADBOOST)
Built the churn prediction model using SAS’s in-memory machine learning procedure:


proc gradboost data=casuser.churn_data_clean; target churn_event / level=nominal; input age income tenure / level=interval; input region plan_type / level=nominal; savestate rstore=casuser.churn_model_gb; run;

4️⃣ Model Evaluation
Assessed the model's performance with ROC and AUC metrics.


proc cas; loadactionset "decisionTree"; rocTable / table={name="churn_data_clean"} rstore="churn_model_gb" target="churn_event" event="1"; quit;

5️⃣ Model Deployment
Published the trained model to SAS Model Manager for real-time and batch scoring.


proc astore; save rstore=casuser.churn_model_gb out=casuser.published_churn_model; run;

The deployed model was integrated with Airtel's customer service systems through REST APIs, allowing real-time churn scoring every time customer data was updated.


πŸ’‘ Business Impact:

"Using this approach in SAS Viya, the business could identify ~78% of high-risk customers before they churned, improving retention through targeted campaigns and saving significant revenue."


Why SAS Viya Was the Right Choice:

  • Distributed in-memory processing with CAS for speed.

  • Integration with Model Manager for model lifecycle governance.

  • REST API deployment — no re-coding required for production.


🎯 Wrap-Up for Interviews:

"This project showed me the full power of SAS Viya — from data prep, model building, and evaluation, to deployment — all within one scalable ecosystem, which makes it especially efficient for large enterprises like telecom operators or banks."



πŸ’‘ Interview Answer: Developing Code and Building Models in SAS Viya

"In my recent experience, I’ve used SAS Viya to develop scalable code and build machine learning models in a cloud-native environment. What I like about Viya is that it combines SAS’s traditional strengths in data manipulation and statistics with modern, distributed computing through its CAS (Cloud Analytic Services) engine."


🧠 Typical Workflow I Follow in SAS Viya


1️⃣ Data Preparation

  • I start by loading data into CAS (Cloud Analytic Services) for in-memory distributed processing.

  • Clean and transform data using either:

    • SAS Code (PROC SQL, DATA Step).

    • Or open-source languages like Python or R via Viya’s APIs.

Example:

cas mySession;
libname casuser cas; data casuser.cleaned_data; set casuser.raw_data; if age >= 18 and status = 'Active'; run;

2️⃣ Exploratory Data Analysis (EDA)

  • Use PROC CASUTILPROC SGPLOT, and SAS Visual Analytics for quick data profiling.

  • Helps spot patterns, outliers, and correlations before model building.


3️⃣ Model Building

  • For modeling, I typically use:

    • PROC FOREST for random forests.

    • PROC GRADBOOST for gradient boosting models.

    • PROC LOGISTIC for classic regression.

    • SAS Viya AutoML or Model Studio for automated model pipelines.

Example: Random Forest Model

proc forest data=casuser.cleaned_data;
target churn_event / level=nominal; input age income tenure / level=interval; input region plan_type / level=nominal; run;

4️⃣ Model Evaluation

  • I validate model performance using:

    • ROC curves and AUC.

    • Confusion matrices.

    • Lift & Gain charts (available in Model Studio or Visual Analytics).


5️⃣ Model Deployment

  • Once the model is ready, I deploy it directly through:

    • SAS Model Manager (for versioning, promotion, and governance).

    • Real-time scoring APIs (if integrated with applications).

    • Batch scoring on new datasets.

Example: Model Publishing

proc astore;
save rstore=casuser.churn_model; run;

πŸ’‘ Why I Like SAS Viya for Model Development

  • Cloud-Native: Supports scale-out computing through Kubernetes and cloud platforms.

  • Open Integration: Allows me to write in SAS or use Python / R interchangeably.

  • Centralized Governance: Models can be promoted and governed using SAS Model Manager.

  • Real-time Deployment: Easy to deploy models via REST APIs, no need to re-code in production.


🎯 Wrap-Up for the Interview:

"So in summary, SAS Viya gives me the flexibility to prepare data, build advanced models, evaluate their performance, and deploy them efficiently — all in a distributed, cloud-friendly environment."


✅ Pro Tip:
If the interviewer follows up, you can also mention that SAS Viya’s AutoML in Model Studio can automatically select algorithms, tune hyperparameters, and export scoring code.


If you want, I can also draft a sample project explanation or code snippet to match a use case like:
πŸ‘‰ fraud detection, customer churn, credit scoring, or sales forecasting.

No comments:

Post a Comment

Python using AI

  Python using AI - Prompts & Codes Tools useful for Python + AI ChatGPT - https://chatgpt.com/ Claude AI - https://claude.ai/new ...