You are on page 1of 44

...

value added solutions for business performance

SAS BI CASE STUDY Course Notes

Submitted by: Ramesh Palanisamy

SAS Competency - Satyam Computer Services Limited.

INTRODUCTION ................................................................................................................................................ 4 ABOUT ORION STAR DATA ............................................................................................................................ 4

1. 2.

RELATIONAL (NORMALIZED) DATA MODEL ............................................................................................... 5 DIMENSIONAL DATA MODEL ..................................................................................................................... 6

SAS MANAGEMENT CONSOLE REGISTER METADATA PROFILE ...................................................... 6 1. 2. 3. 4. METADATA REPOSITORY ......................................................................................................................... 10 SUPPORT FOR DEV/TEST AND PROD ENVIRONMENT IN DI STUDIO ............................................................. 10 SAS DI STUDIO PROCESS ........................................................................................................................ 11 ORION STAR DATA PROCESS IN SAS DI STUDIO ....................................................................................... 12

BUILDING A CUSTOM TREE ........................................................................................................................ 18 DEFINE SOURCE DATA ................................................................................................................................. 22 DEFINE TARGET DATA ................................................................................................................................. 26 CREATE FACT & DIMENSION TABLES ................................................................................................................ 27 1. CREATE FACT TABLE (ORDERFACT) ..................................................................................................... 27 2. PRODUCT DIMENSION (PRODDIM) ........................................................................................................... 35 3. CUSTOMER DIMENSION (CUSTDIM) ......................................................................................................... 38 4. ORGANIZATION DIMENSION (ORGDIM) .................................................................................................... 39 5. TIME DIMENSION (TIMEDIM) ................................................................................................................... 41 6. GEOGRAPHIC DIMENSION (GEODIM)........................................................................................................ 42 DEFINING THE PRIMARY AND FOREIGN KEYS ...................................................................................... 43 1. 2. DEFINE PRIMARY FOR DIMENSION T ABLES............................................................................................... 43 DEFINE PRIMARY KEY FOR FACT TABLE ............................................... ERROR! BOOKMARK NOT DEFINED.

DI PROCESS LIBRARY (TRANSFORMATIONS IN DI STUDIO) ... ERROR! BOOKMARK NOT DEFINED. CREATE ETL JOBS AND LOAD THE TARGET DATA ................... ERROR! BOOKMARK NOT DEFINED. 1. 2. 3. 4. 5. POPULATE THE FACT TABLE (ORDER FACT) .......................................... ERROR! BOOKMARK NOT DEFINED. POPULATE THE PRODUCT DIMENSION (PRODDIM) ................................. ERROR! BOOKMARK NOT DEFINED. POPULATE THE CUSTOMER DIMENSION (CUSTDIM) ............................... ERROR! BOOKMARK NOT DEFINED. POPULATE THE TIME DIMENSION (TIMEDIM) ........................................ ERROR! BOOKMARK NOT DEFINED. POPULATE THE ORGANIZATION DIMENSION (ORGDIM).......................... ERROR! BOOKMARK NOT DEFINED.

DEFINE OLAP CUBE ........................................................................... ERROR! BOOKMARK NOT DEFINED. 1. 2. POPULATE THE DETAIL T ABLE FOR OLAP (DETAILT ABLE) ................... ERROR! BOOKMARK NOT DEFINED. CREATE OLAP CUBE IN DI STUDIO (DWETLCUBE) ............................. ERROR! BOOKMARK NOT DEFINED.

VIEW OLAP DATA USING SAS-ADD IN FOR MS OFFICE ............ ERROR! BOOKMARK NOT DEFINED. VIEW OLAP DATA USING SAS OLAP VIEWER ............................. ERROR! BOOKMARK NOT DEFINED. VIEW OLAP DATA USING SAS ENTERPRISE GUIDE ................... ERROR! BOOKMARK NOT DEFINED. CREATE INFORMATION MAPS ....................................................... ERROR! BOOKMARK NOT DEFINED. VIEW OLAP DATA IN SAS WEB REPORT STUDIO ....................... ERROR! BOOKMARK NOT DEFINED. REFERENCES....................................................................................... ERROR! BOOKMARK NOT DEFINED.

Introduction
This course material provides an overview of SAS BI components and how the data is integrated between each tool (SAS DI Studio, SAS OLAP Cube Studio, SAS MS-Office, Information Map Studio and Web Report Studio). Orion Star data model is used across this course for creating the Relational and Dimensional Data Model and OLAP Cubes.

About Orion Star Data


Orion Star Data Model is organized in two ways as follows  Relational Data Model  Dimensional Data Model Relational Data Model consists of the following tables 1. Country 2. Street_Code 3. City 4. Postal_Code 5. Customer_type 6. Geo_type 7. State 8. Customer 9. Supplier 10. Price_List 11. County 12. Orders 13. Order_Item 14. Product_list 15. Continent 16. Staff 17. Organization 18. Organization_level 19. Product_level 20. Discount 21. TimeData Dimensional Data Model consists of the following tables 1. Order_Fact (Fact table) 2. Customer_Dim 3. Organization_Dim 4. Geography_Dim 5. Product_Dim 6. Time_Dim

1. Relational (Normalized) Data Model

2. Dimensional Data Model

SAS Management Console Register Metadata Profile


Open SAS Management Console from Start-> SAS->SAS Management Console

Select create a new metadata profile for a new profile.

Select Next

Provide a name to the metadata profile and click Next

Provide the Server Name, Port, UserId and Password and click Next

Select Foundation as the Repository and click Next

Click Finish

1. Metadata Repository
There are three types of Repository available in SAS as follows
1) Foundation 2) Custom 3) Project

Foundation will be the default repository and the other two repositories have dependent on the Foundation repository. Metadata administrator defines the repository for each user and provides the details for the user on the repository, user name etc Each user having a separate repository will ensure the authorization of the user for various activities in metadata server (For eg. SASADM user will be the default admin user having full access to the metadata server. A userid XYZ created for a project repository can be controlled by the SASADM and the access is restricted to use. Change management having the check-in and check-out for each ETL jobs are managed in SAS DI studio when a project repository created for each user.

2. Support for Dev/Test and Prod Environment in DI Studio

3. SAS DI Studio Process

4. Orion Star Data Process in SAS DI Studio

SAS Management Console

By Default, SAS Management Console will login with Foundation Repository unless the user profile has assigned a default repository. SAS Main in Management Console lists out the SAS Servers installed and configured.

Defining Library Metadata in DI Studio Open SAS DI studio from Start->SAS->SAS ETL Studio

Select the Inventory tab shown above

Right click on Libraries folder and click New.

Select SAS Base Engine Library and click Next

Enter Staging Library as the library name and description is optional. Click Next

Select the path for Staging Library.

Provide the libref name and click Next

Select SAS Main as the SAS Server and click Next and then click Finish

The new library is registered in Metadata server and displayed in the Libraries folder. Alternatively you can define the above process in SAS Management console for registering the library in Metadata server.

This will invoke the same wizards provided in DI Studio.

Building a custom tree


Select the Custom tab in DI studio as mentioned below.

Right click Foundation and select New Group. Enter Source Tables as the name for the Group.

Repeat the above step again and enter Target Tables as the name for the Group. Once the steps completed, DI Studio will have the two groups available as shown below.

Define Source Data

Click Source Designer and select SAS (All our source data for this case study are in SAS) as the source Data. Click Next

Select the SAS Library as Staging Library and click Next

Select the tables Customer, Order and Order_item and click Next

Select Source Table folder and click Next

Click Finish to load the tables into Source table group.

DI Studio should have the all the table loaded as displayed above. Similar to that, Management Console reflects the tables in metadata server as below.

Repeat the above step (#4) to load the below listed tables
            Customer_type Organization Product Staff Supplier Country County State Continent Postal_Code Geo_Type Street_Code

Define Target Data


Target Designer wizard is used to define the Target tables. The following target tables were defined to build a star schema model

Click Target Designer Icon. A wizard opens to select the type of target table as shown below.

Create Fact & Dimension Tables 1. Create Fact Table (OrderFact)

Select Target table and Click Next

Additional Properties are optional and can be selected to specify notes, table attributes etc Type OrderFact and click Next

Select SAS as DBMS and Staging Library as Library and click Next

Move the following columns to selected column list as shown below

Table Name Order_Item

Column Name Order_ID Product_ID Quantity Total_Retail_Price Cost_Price_Per_Unit Discount Employee_ID Order_Type Order_date Delivery_Date Customer_ID Street_ID

Orders

Customer

Click Next

The New button is required to define any additional columns. Delete button removes the selected column. Select Define Indexes button

Click New and add Customer_ID as the index name. Drag the column Customer_ID to the newly created index as show above. Repeat the above step to add the indexes for Product_ID, Order_date, Order_ID, Street_ID and Employee_ID. The index definition should looks as below.

Select OK and click Next Select Target table as the Group and click Next as shown below

Expand the Target Table group in DI studio, the Order_Fact table should be listed as shown below.

2. Product Dimension (ProdDim)


The following is the list of columns to be imported for creating ProdDim table Source Table Name Product Column Name Product_ID Product_Name Supplier_ID

Supplier

Supplier_Name Country Manually created Columns Product_Category (Char (25)) (These columns need to be Product_Group (Char(25)) created for the target table) Product_Line (Char(20))

Click Next To manually create columns, click New and add the column name and length as shown below

Rename the column name Country as Supplier_Country

Create two simple index for the columns Product_ID and Product_Group as shown below.

3. Customer Dimension (CustDim)


Source Table Name CustType Column Name Customer_ID Country Gender Customer_Name Customer_FirstName Customer_LastName Birth_Date Customer Customer_Type Customer_Group Manually created Columns Customer_Age (Num (8)) (These columns need to be Customer_Age_Group (Num(12)) created for the target table)

a) Rename the following column names Country Gender Birth_date -> -> -> Customer_Country Customer_Gender Customer_Birth_date

b) Create a simple index for the column Customer_ID

4. Organization Dimension (OrgDim)


Source Table Name Organization Column Name Employee_ID Country Org_Name Staff Job_Title Gender Salary Birth_Date Emp_Hire_date Emp_Term_date Manually created Columns Group (Char (40)) (These columns need to be Section (Char (40)) created for the target table) Department (Char (40)) Company (Char (30)) Manager_Levels (Num(8)) Manager_Levels1 (Num(8)) Manager_Levels2 (Num(8)) Manager_Levels3 (Num(8)) Manager_Levels4 (Num(8)) Manager_Levels5 (Num(8))

Manager_Levels6 (Num(8)) a) Rename the following column names Country Org_Name Gender Birth_date -> -> -> -> Employee_Country Employee_Name Employee_Gender Employee_Birth_date

b) Create a simple index for the column Customer_ID

5. Time Dimension (TimeDim)


Source Table Name Column Name Manually created Columns Date_ID (Num(4)) format DATE9. (These columns need to be Weekday_Num (Num(3)) created for the target table) Weekday_Name (Char(20)) Week_Num (Num(3)) Week_Name (Char(7)) Month_Num (Num(3)) Month_Name (Char (20)) Quarter (Char(6)) Year_ID (Char(4)) Holiday_US (Char (45)) Fiscal_Year (Char(4)) Fiscal_Quarter (Char(6)) Fiscal_Month_Num (Num(3)) a) Create a simple index for the column Date_ID

6. Geographic Dimension (GeoDim)


Source Table Name Continent Country State County Column Name Continent_Name Country_Name State_Code State_Name Region_Name Province_Name County_Name City Postal_Code Street_Name

City Postal_Code Street_Code

Final list of Source and Target table should have all the tables as mentioned below.

Defining the Primary and Foreign Keys


This demonstration illustrates adding the Primary and Foreign keys for the Fact and Dimensional tables.

1. Define Primary for Dimension Tables


1. 2. 3. 4. Right Click on CustDim and select Properties Select the Keys tab and select on Customer_ID column. Select the New button and click Primary Key Primary Key for the column Customer_ID is defined and the window should look as below.

Repeat the above steps for other tables with the following parameters to define the primary key. Note: If the Primary Column is not found in any of the table mentioned below, it can be imported from the source table. GeoDim table needs Street_ID as the primary key column which is not available in the table. This column needs to be imported using the below steps.

 Right Click GeoDim table and select Properties from the pop-up menu  Select the Columns tab and select Import.

 Select Source table folder and expand Street_code table and select Street_ID column as shown below and click OK

 The column Street_ID is now added into the GeoDim table as shown below.

You might also like