This is part of a series on technical use cases, designed to help SAS users solve a particular business or technical challenge.
The challenge: Create a dashboard that monitors credit risk of credit card customers, such as the average credit score over time, key risk indicators, and expected loss. This scenario uses both SAS Studio and SAS Visual Analytics.
Goal: Load raw credit card customer data into SAS Viya’s in-memory CAS environment for fast processing. We will use SAS Data Explorer for this import.
Goal: Confirm that the data imported correctly and prepare SAS Studio for data manipulation by ensuring an active CAS session.
cas; CASLIB _ALL_ assign;
NOTE: The session name identified with the SESSREF= SAS option is connected to Cloud Analytic Services.
proc contents data=casuser.accounts;
run;
This will display metadata (including the number of observations) for ACCOUNTS. Seeing the correct counts confirms a successful import.
At this point, the raw data is loaded and verified in CAS, and SAS Studio is ready for data preparation steps.
If you prefer code or need to automate data loading, SAS provides code-based methods.
To load the performance CSV via code from a network fileshare, you can use a PROC IMPORT step:
proc import
file='/location/to/file/performance.csv'
out=casuser.performance
dbms=csv
replace;
run;
If you uploaded your data to SAS Content rather than a network fileshare, you must use the FILESRVC access method in a FILENAME statement to load the file:
filename perfcsv filesrvc
path='/location/to/file'
filename='performance.csv';
proc import
file=perfcsv
out=casuser.performance
dbms=csv
replace;
run;
This code loads the CSV from the specified path into the CASUSER CASLIB as a table named PERFORMANCE. You would do a similar step for accounts.csv. Check the SAS log for notes confirming the load. After running, verify the new tables appear in CASUSER and have the expected content (as in Step 2).
This step is not required if you already imported the data via the Data Explorer UI, but it’s useful for automation or documentation purposes.
Goal: Prepare the data for analysis by cleaning any issues and combining the data sources into a unified dataset. This involves standardizing columns, handling missing or duplicate entries, and merging the account info with monthly performance records.
data casuser.accountsaccount_monthly;
merge casuser.accounts(in=a)
casuser.performance(in=p);
by customer_id;
if(a);
run;
This performs a left join that is functionally equivalent to FEDSQL so that each monthly performance record (p) is augmented with the corresponding account info (a). The result ACCOUNT_MONTHLY will have multiple rows per Customer_ID – one for each month (or period) of performance, carrying along static attributes from the account table. All accounts will be retained, even if they do not have a performance field.
proc sort data=account_monthly nodupkey
out=casuser.account_monthly_unique
dupout=casuser.dup_accounts;
run;
This will remove any duplicate Customer_ID entries and output them to dup_accounts for review. Ideally, dup_accounts will be empty. This means each customer appears only once in accounts. If not, you may need to reconcile which record to keep using a strategy that makes the most sense for your application. For example, you could keep only the latest info for that customer.
Result: You now have an integrated dataset ACCOUNT_MONTHLY with each customer’s account details and their monthly performance metrics combined. This is the basis for calculating risk features and metrics.
Goal: Create new variables that capture credit risk indicators, to be used in the dashboard. These features quantify aspects like credit utilization, payment behavior, credit score changes, and expected loss components. Many can be derived from the combined dataset on a per-record or per-customer basis.
Key features to engineer:
You can derive these features with SAS code or derive these columns in SAS Visual Analytics. It is generally preferable to use derived columns in SAS Visual Analytics whenevr possible to reduce the overall size of the underlying dataset. For example, if you need to do a simple aggregation, create a flag, create a group such as utilization category, or do some basic math on a few values, you should do this in Visual Analytics as these on-the-fly calculations are done very efficiently. The best thing to do is to try to create the calculation in Visual Analytics first. If you are unable to do the calculation in Visual Analytics, such as with a lag or a lead, or if you need to join tables within Visual Analytics, then you should go back to your data and create those columns prior to loading into Visual Analytics. It is advisable to avoid doing joins in Visual Analytics for dashboards that will be accessed by many users since this creates a new unique table for every user who views the dashboard.
Goal: Make the prepared data available to SAS Visual Analytics by promoting it to global scope in CAS. By default, tables created in CAS are tied to your session and will disappear when your session ends unless you upload it through the interface which automatically promotes and saves tables to a backing store. In CAS, the default state of a table you create with code is temporary no matter which CASLIB you put it in. Think of it kind of like the WORK directory: all your datasets disappear when your session ends, except it's like this for any CASLIB. Promotion ensures the table persists and is accessible for reporting.
proc casutil incaslib='casuser' outcaslib='public';
promote casdata='account_monthly_features';
quit;
This takes the ACCOUNT_MONTHLY_FEATURES table from the CASUSER CASLIB and promotes it within CASUSER. You should change outcaslib to a shared CASLIB like Public if you want other users to see it. Using CASUSER for promotion means it’s global only to you. Think of CASUSER like your SASUSER library: it's a place for your semi-permanent or permanent files, but other people cannot access it.
Note that the data is loaded to memory only. If CAS restarts, the data will be unloaded and you will need to run your pipeline again. To ensure that your dashboard will function correctly if this happens, you need to create a persistent data store. Visual Analytics knows where your data is, and if it is unloaded from memory, it will automatically load it. To do this, run the following code:
proc casutil incaslib='public' outcaslib='public';
save casdata='account_monthly_features' replace;
quit;
Your data is now permanently saved to a backing store (in this case, a physical disk) and can be reloaded by Visual Analytics if it is unloaded.
In Part 2, we'll show you how to build the credit risk dashboard in SAS Visual Analytics.
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.