Creating the Date Dimension

Slides:



Advertisements
Similar presentations
Effecting Efficiency Effortlessly Daniel Carden, Quanticate.
Advertisements

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Introduction to Rails.
Haas MFE SAS Workshop Lecture 3:
When Good Looks Arent Enough Lisa Eckler. When Good Looks Arent Enough.
© Abdou Illia MIS Spring 2014
Dimensional Modeling.
Creating Tables. 2 home back first prev next last What Will I Learn? List and provide an example of each of the number, character, and date data types.
Dates and Times SAS Date, Time and Date- Time Formats.
Database Chapters.
Examples from SAS Functions by Example Ron Cody
Virtual training week 4 structured query language (SQL)
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)MySQL Recap.
Representing Data Elements Gayatri Gopalakrishnan.
PowerPoint Presentation for Dennis & Haley Wixom, Systems Analysis and Design Copyright 2000 © John Wiley & Sons, Inc. All rights reserved. Slide 1 Key.
Introduction to Structured Query Language (SQL)
Winter 2002Judy Cushing8–1 Schedule Jan. 30 (Wed) u Modifications, Schemas, Views. Read Sections This Week (Feb 4ff) u Constraints Read Sections.
Databases Lab 5 Further Select Statements. Functions in SQL There are many types of functions provided. The ones that are used most are: –Date and Time.
DT211 Stage 2 Databases Lab 1. Get to know SQL Server SQL server has 2 parts: –A client, running on your machine, in the lab. You access the database.
Introduction to Structured Query Language (SQL)
Basic And Advanced SAS Programming
SQL Tutorials To understand some of the topics please analyze the following tutorials: The following tutorials will help:
Data Transformation Data cleaning. Importing Data Reading data from external formats Libname/Infile/Input for text form data Proc Import for Excel/Access.
Copying, Managing, and Transforming Data With DTS.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
Database Systems Lecture 5 Natasha Alechina
Chapter 18: Modifying SAS Data Sets and Tracking Changes 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Creating SAS® Data Sets
Project Implementation for COSC 5050 Distributed Database Applications Lab5.
MySql In Action Step by step method to create your own database.
Structured Query Language (SQL) A2 Teacher Up skilling LECTURE 2.
Chapter 9 SQL and RDBMS Part C. SQL Copyright 2005 Radian Publishing Co.
SAS SQL SAS Seminar Series
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Copyright  Oracle Corporation, All rights reserved. 4 CMIS Powell Oracle Designer: Creating the Database Design CMIS Powell.
 A database is a collection of data that is organized so that its contents can easily be accessed, managed, and updated. What is Database?
©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.
Prepared by: Luigi Muro – Consultant
SQL, Data Storage Technologies, and Web-Data Integration Week 2.
Lesson 2 Topic - Reading in data Chapter 2 (Little SAS Book)
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Recap of SQL Lab no 8 Advance Database Management System.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 8 Advanced SQL.
Jessica Bennett, Advance America Barbara Ross, Flexshopper LLC PharmaSUG 2015 Paper #QT06.
MySQL More… 1. More on SQL In MySQL, the Information Schema is the “Catalog” in the SQL standard SQL has three components: Data definition Data manipulation.
CS499 Project #3 XML mySQL Test Generation Members Erica Wade Kevin Hardison Sameer Patwa Yi Lu.
Advanced SQL: Triggers & Assertions
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Visual Programing SQL Overview Section 1.
SQL John Nowobilski. What is SQL? Structured Query Language Manages Data in Database Management Systems based on the Relational Model Developed in 1970s.
PowerBuilder Online Courses - by Prasad Bodepudi Database Painter Primary & Foreign Keys Extended Attributes PowerBuilder System Tables Database Profiles.
Chapter 17: Formatting Data 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Copyright © 2004, SAS Institute Inc. All rights reserved. SASHELP Datasets A real life example Barb Crowther SAS Consultant October 22, 2004.
Chapter 8 Views and Indexes 第 8 章 视图与索引. 8.1 Virtual Views  Views:  “virtual relations”. Another class of SQL relations that do not exist physically.
SQL server Section 2&3. What are Data Types Character Data Types Number Data Types Date and Time Data Types CAST and CONVERT functions TRY_PARSE and TRY_CONVERT.
CpSc 3220 The Language of SQL Chapter 17 Modifying Data.
Microsoft Access Prepared by the Academic Faculty Members of IT.
1 DBS201: More on SQL Lecture 2. 2 Agenda Select command review How to create a table How to insert data into a table.
Lesson 2 Topic - Reading in data Programs 1 and 2 in course notes –Chapter 2 (Little SAS Book)
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
Introduction to Databases & SQL Ahmet Sacan. What you’ll need Firefox, SQLite plugin Mirdb and Targetscan databases.
Copyright 2009 The Little Engine That Could: Using EXCEL LIBNAME Engine Options to Enhance Data Transfers between SAS® and Microsoft® Excel Files William.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 5 & 6 By Ravi Mandal.
Insert, Update and the rest…
ETL Processing Mechanics of ETL.
Retrieving Macro Variables in the DATA Step
Assignment 2 Due Thursday Feb 9, 2006
ETL Processing Mechanics of ETL.
SQL (Structured Query Language)
Login Main Functions Via SAS Information Delivery Portal
Presentation transcript:

Creating the Date Dimension Using SQL and SAS to process dates.

Base E-R Diagram

Create DateSurrogates Index CREATE TABLE DateSurrogates (OrderDate Date CONSTRAINT pk PRIMARY KEY, Surrogate AUTOINCREMENT, DateKey Integer);

Create Date Key INSERT INTO DateSurrogates (OrderDate) SELECT DISTINCT OrderDate FROM OrdersCopy WHERE OrderDate NOT IN (SELECT OrderDate FROM DateSurrogates);

Update DateKey UPDATE DateSurrogates SET DateKey = Surrogate WHERE DateKey IS Null;

DateSurrogatesTable DateSurrogates: OrderDate Date/Time Surrogate Autoincrement DateKey Integer

Importing Into SAS PROC IMPORT OUT= WORK.CUSTOMER DATATABLE= "DateSurrogates“ DBMS=ACCESS2000 REPLACE; DATABASE="C:\DataWarehousing04s\ETL\PremiereExtractExample.mdb"; RUN;

Results of Proc Contents ----Alphabetic List of Variables and Attributes----- # Variable Type Len Pos Format Informat Label 3 DateKey Num 8 16 11. 11. DateKey 1 OrderDate Num 8 0 DATETIME20. DATETIME20. OrderDate 2 Surrogate Num 8 8 11. 11. Surrogate

SAS Date and Time Functions and Formats SAS has a number of useful functions for working with dates and times. Their options depend on the data type of the variable. DATETIME stores both the date and time DATE stores date information (in days from January 1, 1960) TIME stores time information (in seconds.fraction)

Functions Functions take values and convert the way the data is stored Function Use Datapart Takes a datetime attribute, extracts the date part and stores it as a date attribute Timepart Takes a datetime attribute, extracts the time part and stores it as a Time attribute

Functions Function Use Use Put(attribute, format) Input(attribute, informat) Use Returns a (character) value using a specified format. Returns the value produced when a SAS expression is read using a specified informat.

Formats and Informats Formats determine how a variable is displayed; informats determine how a variable id read. The tend to be similar. FORMATNAMEw.d Formats and Informats always contain a period (.) SAS makes assumptions about the best display for a given w.d specification

Some Useful Formats YEARw. MONNAMEw. DOWNAMEw. QTRw. JULDAYw. Writes date values as the year Writes date values as the quarter of the year Writes data values as the the name of the day of the week writes dates as the Julian day of the year (yyddd). For w=3 the output is ddd.