Published on :
ETL CREATION_INTERNE

Applying Labels and Formats

This code is also available in: Deutsch Español Français
Awaiting validation
This example demonstrates how to use the `table.alterTable` action in SAS© Cloud Analytic Services (CAS) to modify table column properties, including applying descriptive labels and numeric formats. The code begins with the `CAS` procedure to interact with the CAS server. The `table.alterTable` action is used to specify labels and formats for columns such as 'Customer_Name', 'Payment_History', 'Credit_Score', 'Total_Debt', 'State_FIPS', 'Income', and 'Region_FIPS'. Then, the `table.fetch` action is employed to retrieve and display a subset of the 'creditscores' table columns, applying the newly defined labels and formats. A DATA STEP block is added to create a demonstration 'creditscores' table to make the example self-contained.
Data Analysis

Type : CREATION_INTERNE


Examples use generated data (datalines).

1 Code Block
PROC CAS / DATA STEP Data
Explanation :
The data block creates a temporary table named 'creditscores' with example data for the columns 'Customer_Name', 'Payment_History', 'Credit_Score', 'Total_Debt', 'State_FIPS', 'Region_FIPS', 'Age', and 'Income'.

The PROC CAS procedure initializes a session with the CAS server.
The `table.alterTable` action is used to modify the structure of the 'creditscores' table by applying more descriptive labels and specific display formats for certain columns like 'Payment_History' (percentage format) and 'Total_Debt', 'Income' (currency format).
Finally, the `table.fetch` action is used to retrieve and display a specified subset of the 'creditscores' table variables ('Customer_Name', 'State', 'Age', 'Income', 'Payment_History', 'Credit_Score', 'Total_Debt', 'State_FIPS', 'Region_FIPS'). The `index=false` option is used to not include the index variable in the result.
Copied!
1DATA work.creditscores;
2 INPUT Customer_Name $ Payment_History Credit_Score Total_Debt State_FIPS Region_FIPS Age Income;
3 DATALINES;
4"John Doe" 0.95 750 15000 12345 67890 35 60000
5"Jane Smith" 0.80 680 25000 54321 09876 42 80000
6"Peter Jones" 0.90 700 10000 98765 43210 28 45000
7"Alice Brown" 0.70 600 30000 11223 44556 50 90000
8;
9RUN;
10 
11PROC CAS;
12 TABLE.alterTable / columns={
13 {label="Customer Name", name="Customer_Name"},
14 {label="Payment History", FORMAT="percent.", name="Payment_History"},
15 {label="Credit Score", name="Credit_Score"},
16 {label="Total Debt", FORMAT="dollar10.", name="Total_Debt"},
17 {label="State FIPS", name="State_FIPS"},
18 {FORMAT="dollar10.", name="Income"},
19 {label="Region FIPS", name="Region_FIPS"}},
20 name="creditscores";
21 TABLE.fetch / TABLE="creditscores"
22 fetchvars={"Customer_Name", "State", "Age", "Income",
23 "Payment_History", "Credit_Score",
24 "Total_Debt", "State_FIPS", "Region_FIPS"},
25index=false;
26QUIT;
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