sessionProp addFmtLib

Standard Workflow: Customer Segmentation for Marketing Campaign

Scénario de test & Cas d'usage

Business Context

The marketing department needs to analyze campaign outreach results. They require custom formats to segment customers by age group and geographical region, which are not standard in their data. This scenario tests the fundamental process of creating, loading, and applying a user-defined format library from a CAS table.
About the Set : sessionProp

Configuration of session properties.

Discover all actions of sessionProp
Data Preparation

Create a control data set for customer segmentation formats (age and region) and a sample customer table.

Copied!
1/* Create formats in WORK */
2PROC FORMAT;
3 value $regionfmt 'NA'='North America' 'EU'='Europe' 'AS'='Asia' other='Other';
4 value agegroupfmt low-24='Gen Z' 25-40='Millennial' 41-55='Gen X' 56-high='Boomer';
5RUN;
6 
7/* Create control data set from formats */
8DATA work.marketing_formats_ctl;
9 SET sashelp.vformat;
10 where fmtname in ('REGIONFMT', 'AGEGROUPFMT');
11RUN;
12 
13/* Create sample customer data */
14DATA work.customer_list;
15 LENGTH CustomerID $ 10 Region $ 2;
16 INPUT CustomerID Region Age;
17 DATALINES;
18CUST001 NA 35
19CUST002 EU 50
20CUST003 NA 22
21CUST004 AS 68
22CUST005 XX 45
23;
24RUN;

Étapes de réalisation

1
Load the format control data set and the customer list into the 'casuser' caslib.
Copied!
1PROC CASUTIL;
2 load DATA=work.marketing_formats_ctl outcaslib='casuser' casout='marketing_formats_table' replace;
3 load DATA=work.customer_list outcaslib='casuser' casout='customer_list_cas' replace;
4QUIT;
2
Add the format library to the session from the CAS table.
Copied!
1PROC CAS;
2 sessionProp.addFmtLib /
3 caslib='casuser'
4 name='marketing_formats_table'
5 fmtLibName='MarketingLib';
6RUN;
3
Verify the formats are applied correctly by running a frequency analysis.
Copied!
1PROC CAS;
2 SIMPLE.freq /
3 TABLE={name='customer_list_cas', caslib='casuser'}
4 inputs={{name='Age', FORMAT='AGEGROUPFMT'}, {name='Region', FORMAT='REGIONFMT'}};
5RUN;

Expected Result


The `simple.freq` action should produce two frequency tables. The first table for 'Age' will show counts grouped by the 'agegroupfmt' labels ('Millennial', 'Gen X', 'Gen Z', 'Boomer'). The second table for 'Region' will show counts grouped by the '$regionfmt' labels ('North America', 'Europe', 'Asia', 'Other'). This confirms the 'MarketingLib' format library was successfully loaded and applied.