Effective Use of SQL in SAS Programming

Size: px
Start display at page:

Download "Effective Use of SQL in SAS Programming"

Transcription

1 INTRODUCTION Effective Use of SQL in SAS Programming Yi Zhao Merck & Co. Inc., Upper Gwynedd, Pennsylvania Structured Query Language (SQL) is a data manipulation tool of which many SAS programmers are unaware, or not comfortable. Using fewer lines of code as well as achieving improved performance, SQL can accomplish the same goal as many SAS data steps. This paper gives a brief introduction on the subject of relational databases and SQL syntax followed by a variety of tips on how to use SQL effectively in SAS programming. RELATIONAL DATABASE SQL is primarily designed as a programming language to work with relational databases. Many of the features of SQL are directly related to database activities such as retrieving data, updating or deleting data, and so on. In relational databases, relations or tables are associated to each other by primary keys and foreign keys. Primary keys are used to identify each row in a table uniquely and foreign keys are used to maintain the integrity of the database. Many of the SQL primary keys and foreign keys are similar to variables used in the SAS by-merge data step. A database schema is used to describe the structure and relationship among tables. Using SQL gives the ability to check the schema to find common variables between tables and variable attributes such as data type, format, etc. To make data retrieval or updating more efficient, SQL can create and use a database index. This is similar to SAS Proc SQL where we could create and store an index within a dataset when working with large datasets. Using SQL, views or virtual tables can be created to manipulate data in exactly the same way as they are created in SAS Proc SQL. In summary, knowing the basics of SQL in relational database can help SAS programmers develop better SAS code. SQL BASICS SQL Structured Query Language - developed by IBM in the early 1970s, is a standard interactive and programming language for querying, modifying data, and managing databases. The basic syntax is shown in the following example: Select d.subjid, d.treat_cd, a.exam_val From demos d, assy a Where d.subjid = a.subjid Group by d.treat_cd Order by d.subjid; 1

2 Although SQL is both an ANSI and an ISO standard, many database products support SQL with proprietary extensions to the standard language such as Oracle SQL, SQL Server, MySQL, and so on. Proc SQL is the SAS version of SQL. Proc SQL adopts most of the standard SQL features with additional SAS ingredients such as dataset options, SAS functions, etc. As a result, SAS SQL has the power of regular SQL and many SAS special add-on features. TERMINOLOGY To help less-experienced SAS programmers better understand the different terms used by database SQL programmers and SAS programmers, a comparison of these terms is displayed in Table 1 below: Table 1: Comparison of SQL Terminology SAS Term Database Term SQL Term Dataset Relation Table Observation Tuple Row Variable Attribute Column Merge Join Join Missing value NULL NULL USE OF SQL IN SAS SAS uses SQL in two different ways Where statement and Proc SQL. Where statement is one of the most commonly used SAS statements. The concept and syntax, however, were originally adopted from SQL - this is one example that SAS is a powerful language that imports and mixes syntax from other languages. Proc SQL is the main tool within SAS to use SQL. While Proc SQL is a SAS procedure, it performs many functions similar to those found within SAS data steps. Often, for data manipulation, data step or Proc SQL can be used either individually or interchangeably. Four major areas which describe the effective use of SQL in SAS Proc SQL are outlined in the following sections. I. Access Relational Database In SAS, there are two approaches to access relational databases. One is the LIBNAME Statement and the other is the pass-through facility. Below is an example of the passthrough facility. The code is to read a demographic table from an Oracle database and output all those allocated subjects. 2

3 connect to odbc (dsn=&dsn uid=&uid pwd=&pwd); create table demo as select * from connection to odbc (select distinct allocation_number subjid, visit_number vt_num, age from std_demos where allocation_number is not null ); disconnect from odbc; Programming Tips: Get login credentials from interactive Window input for security reasons. Do not use multiple joins to retrieve data - it is more efficient if multiple CREATE TABLE statements are used. If possible, avoid the use of ORDER BY to speed up execution. Use index if available. II. Create Macro Variables Using the Into Clause SAS programmers often use %LET or SAS function CALL SYMPUT() to create macro variables. The following is an example: Data _null_; set dup nobs=obs; call symput( totdup', compress(put(obs, best.))); There is an alternative approach to achieving the same result by using the following SQL procedure: Proc sql noprint; select count(*) into : totdup from dup; The Into clause stores the value of one or more columns in macro variable(s) for use later in another Proc SQL query or SAS statement - below is an example: Proc sql noprint; select count (distinct treat_cd) into : tot_trt from sero_all; select distinct treat_cd into :_trt1 - :_trt&tot_trt from sero_all; 3

4 The above code creates a macro variable &TOT_TRT to store the total number of treatment groups, creates macro variables &TRT1, &TRT2, and stores the names of treatment groups in them. The total number of macro variables is determined by the value in &TOT_TRT. Following is another example using an automatic macro variable &SQLOBS: Proc sql noprint; create table count_by as select distinct (&byvar) from datadir.&inds; select &byvar into :byv1 - :byv&sqlobs from count_by; Programming Tips: &Sqlobs is an automatic macro variable created by SAS to store the number of observations in a dataset. It is similar to _null_ in data step. Use option Noprint to prevent printing to the SAS list. No need to repeat Proc SQL for each SQL statement. Separate variables with a comma, not a space. Use Distinct to select unique observations. Use Quit, not Run, at the end. III. Merge (Join) Tables The biggest advantage of a SQL join is that there is no need for sorting and renaming which is especially useful when dealing with large datasets. The following is corresponding code for a by-merge data step and SQL join: Proc sort data = one; Proc sort data = two (rename = (an_num = subjid)); Data three; Merge one two; Run; Merge (Join) Create table three as Select * From one, two Where one.subjid = two.an_num; Quit; There are two kinds of joins in SQL: inner join and outer join. An inner join returns a result table for all the rows in a table that have one or more matching rows in the other 4

5 table(s). The example above is an implied inner join and can be re-written with specific inner join key words as shown below: Proc sort data = one; Proc sort data = two (rename = (an_num = subjid)); Data three; Merge one(in=a) two(in=b); If a and b; Run; Inner Join Create table three as Select * From one INNER JOIN two ON one.subjid = two.an_num; Quit; Outer joins are inner joins that have been augmented with rows that did not match with any row from the other table in the joins. The three types of outer joins are left, right, and full join. Below are examples of outer joins: Proc sort data = one; Proc sort data = two (rename = (an_num = subjid)); Data three; Merge one(in=a) two(in=b); If a; Run; Left Join Create table three as Select * From one LEFT JOIN two ON one.subjid = two.an_num; Quit; 5

6 Proc sort data = one; Proc sort data = two (rename = (an_num = subjid)); Data three; Merge one(in=a) two(in=b); If b; Run; Right Join Create table three as Select * From one RIGHT JOIN two ON one.subjid = two.an_num Quit; A full outer join, specified with the keywords FULL JOIN and ON, returns all the rows from all the tables regardless of whether they match. The full outer join is rarely used in the real world. IV. Transform Data SQL is used frequently for creating, renaming new variables, and ordering output. Suppose we have the following task at hand: Create a new variable new_v1 by concatenating v1 and v2 Create a new variable new_v2 as the sum of v3 Rename v4 and v5 as out4 and out5 Only output new_v1, new_v2, out4, out5, v3 and in that particular order in the output dataset Here is the code: create table new as select v1 v2 as new_v1, sum(v3) as new_v2, v4 as out4, v5 as out5, v3 from old; Programming Tips: SAS dataset options such as keep, drop, rename and SAS functions can be used within Proc SQL. Here is an example: %let label=this is the label; create table one (label="&label" drop=subject_no center) as select * from tx t1, 6

7 scores t2 where t1.subject_no=input(substr(t2.subject_id,5),8.) and t1.center=input(substr(t2.subject_id,1,3),8.); Use of a sub query or in-line view. A query-expression is called subquery when used in WHERE or HAVING clauses. It is nested as part of another query-expression. An in-line view is a special subquery used in the FROM clause. This can be used in situations such as identifying those patients who are older than the average age of all patients and who experienced an Adverse Event. Select subjid, birth_dt, age, gender from std_demos where age > (select avg(age) from std_demos) and subjid in (select distinct subjid from std_ae) order by subjid; Use of set operators like UNION, INTERSECT, EXCEPT Should avoid Cartesian product which is similar to SAS merge without by variable(s) CONCLUSION Proc SQL is more powerful and efficient than SAS data steps in certain cases, with fewer lines of code. SQL is a basic tool for many job functions that involve working with databases. Mastering SQL could result in project (or job) opportunities and enhance career growth. Proc SQL must be used wisely or it can become complicated and inefficient.. In summary, Proc SQL is an excellent alternative to non-sql Base SAS, making it worth the programmers' time to explore its use. REFERENCES Feng, Ying Tips for Using SQL: When to Use and How?" Proceedings of the 18th Annual NorthEast SAS Users Group Conference, POS12, SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. indicates USA 7

8 registration. Other brand and product names are trademarks of their respective companies. AUTHOR CONTACT INFORMATION Yi Zhao Senior Scientific Programming Analyst Merck Research Laboratories UG1CD-38 PO Box 1000 North Wales, PA Phone:

Chapter 9 Joining Data from Multiple Tables. Oracle 10g: SQL

Chapter 9 Joining Data from Multiple Tables. Oracle 10g: SQL Chapter 9 Joining Data from Multiple Tables Oracle 10g: SQL Objectives Identify a Cartesian join Create an equality join using the WHERE clause Create an equality join using the JOIN keyword Create a non-equality

More information

Outline. SAS-seminar Proc SQL, the pass-through facility. What is SQL? What is a database? What is Proc SQL? What is SQL and what is a database

Outline. SAS-seminar Proc SQL, the pass-through facility. What is SQL? What is a database? What is Proc SQL? What is SQL and what is a database Outline SAS-seminar Proc SQL, the pass-through facility How to make your data processing someone else s problem What is SQL and what is a database Quick introduction to Proc SQL The pass-through facility

More information

Oracle SQL. Course Summary. Duration. Objectives

Oracle SQL. Course Summary. Duration. Objectives Oracle SQL Course Summary Identify the major structural components of the Oracle Database 11g Create reports of aggregated data Write SELECT statements that include queries Retrieve row and column data

More information

Oracle Database 12c: Introduction to SQL Ed 1.1

Oracle Database 12c: Introduction to SQL Ed 1.1 Oracle University Contact Us: 1.800.529.0165 Oracle Database 12c: Introduction to SQL Ed 1.1 Duration: 5 Days What you will learn This Oracle Database: Introduction to SQL training helps you write subqueries,

More information

SQL SUBQUERIES: Usage in Clinical Programming. Pavan Vemuri, PPD, Morrisville, NC

SQL SUBQUERIES: Usage in Clinical Programming. Pavan Vemuri, PPD, Morrisville, NC PharmaSUG 2013 Poster # P015 SQL SUBQUERIES: Usage in Clinical Programming Pavan Vemuri, PPD, Morrisville, NC ABSTRACT A feature of PROC SQL which provides flexibility to SAS users is that of a SUBQUERY.

More information

Oracle Database: SQL and PL/SQL Fundamentals

Oracle Database: SQL and PL/SQL Fundamentals Oracle University Contact Us: 1.800.529.0165 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This course is designed to deliver the fundamentals of SQL and PL/SQL along

More information

Oracle Database 10g: Introduction to SQL

Oracle Database 10g: Introduction to SQL Oracle University Contact Us: 1.800.529.0165 Oracle Database 10g: Introduction to SQL Duration: 5 Days What you will learn This course offers students an introduction to Oracle Database 10g database technology.

More information

SAS SQL #2. Grouping Data Using GROUP BY Clause to group data by a column or columns

SAS SQL #2. Grouping Data Using GROUP BY Clause to group data by a column or columns SAS SQL #2 JC Wang Grouping Data Using GROUP BY Clause to group data by a column or columns GROUP BY input-column1 usually used with an aggregate function in the SELECT clause or in

More information

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff D80198GC10 Oracle Database 12c SQL and Fundamentals Summary Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff Level Professional Delivery Method Instructor-led

More information

Oracle Database: SQL and PL/SQL Fundamentals

Oracle Database: SQL and PL/SQL Fundamentals Oracle University Contact Us: +966 12 739 894 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training is designed to

More information

Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle Database: SQL and PL/SQL Fundamentals NEW Oracle University Contact Us: + 38516306373 Oracle Database: SQL and PL/SQL Fundamentals NEW Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training delivers the

More information

MOC 20461C: Querying Microsoft SQL Server. Course Overview

MOC 20461C: Querying Microsoft SQL Server. Course Overview MOC 20461C: Querying Microsoft SQL Server Course Overview This course provides students with the knowledge and skills to query Microsoft SQL Server. Students will learn about T-SQL querying, SQL Server

More information

Using SAS With a SQL Server Database. M. Rita Thissen, Yan Chen Tang, Elizabeth Heath RTI International, RTP, NC

Using SAS With a SQL Server Database. M. Rita Thissen, Yan Chen Tang, Elizabeth Heath RTI International, RTP, NC Using SAS With a SQL Server Database M. Rita Thissen, Yan Chen Tang, Elizabeth Heath RTI International, RTP, NC ABSTRACT Many operations now store data in relational databases. You may want to use SAS

More information

Paper 70-27 An Introduction to SAS PROC SQL Timothy J Harrington, Venturi Partners Consulting, Waukegan, Illinois

Paper 70-27 An Introduction to SAS PROC SQL Timothy J Harrington, Venturi Partners Consulting, Waukegan, Illinois Paper 70-27 An Introduction to SAS PROC SQL Timothy J Harrington, Venturi Partners Consulting, Waukegan, Illinois Abstract This paper introduces SAS users with at least a basic understanding of SAS data

More information

Foundations & Fundamentals. A PROC SQL Primer. Matt Taylor, Carolina Analytical Consulting, LLC, Charlotte, NC

Foundations & Fundamentals. A PROC SQL Primer. Matt Taylor, Carolina Analytical Consulting, LLC, Charlotte, NC A PROC SQL Primer Matt Taylor, Carolina Analytical Consulting, LLC, Charlotte, NC ABSTRACT Most SAS programmers utilize the power of the DATA step to manipulate their datasets. However, unless they pull

More information

Oracle 10g PL/SQL Training

Oracle 10g PL/SQL Training Oracle 10g PL/SQL Training Course Number: ORCL PS01 Length: 3 Day(s) Certification Exam This course will help you prepare for the following exams: 1Z0 042 1Z0 043 Course Overview PL/SQL is Oracle's Procedural

More information

Programming with SQL

Programming with SQL Unit 43: Programming with SQL Learning Outcomes A candidate following a programme of learning leading to this unit will be able to: Create queries to retrieve information from relational databases using

More information

SQL Development Using Oracle

SQL Development Using Oracle SQL Development Using Oracle Course Summary Identify the major structural components of the Oracle Database 11g Create reports of aggregated data Write SELECT statements that include queries Retrieve row

More information

CHAPTER 1 Overview of SAS/ACCESS Interface to Relational Databases

CHAPTER 1 Overview of SAS/ACCESS Interface to Relational Databases 3 CHAPTER 1 Overview of SAS/ACCESS Interface to Relational Databases About This Document 3 Methods for Accessing Relational Database Data 4 Selecting a SAS/ACCESS Method 4 Methods for Accessing DBMS Tables

More information

Using the SQL Procedure

Using the SQL Procedure Using the SQL Procedure Kirk Paul Lafler Software Intelligence Corporation Abstract The SQL procedure follows most of the guidelines established by the American National Standards Institute (ANSI). In

More information

REx: An Automated System for Extracting Clinical Trial Data from Oracle to SAS

REx: An Automated System for Extracting Clinical Trial Data from Oracle to SAS REx: An Automated System for Extracting Clinical Trial Data from Oracle to SAS Edward McCaney, Centocor Inc., Malvern, PA Gail Stoner, Centocor Inc., Malvern, PA Anthony Malinowski, Centocor Inc., Malvern,

More information

Managing Tables in Microsoft SQL Server using SAS

Managing Tables in Microsoft SQL Server using SAS Managing Tables in Microsoft SQL Server using SAS Jason Chen, Kaiser Permanente, San Diego, CA Jon Javines, Kaiser Permanente, San Diego, CA Alan L Schepps, M.S., Kaiser Permanente, San Diego, CA Yuexin

More information

Using DATA Step MERGE and PROC SQL JOIN to Combine SAS Datasets Dalia C. Kahane, Westat, Rockville, MD

Using DATA Step MERGE and PROC SQL JOIN to Combine SAS Datasets Dalia C. Kahane, Westat, Rockville, MD Using DATA Step MERGE and PROC SQL JOIN to Combine SAS Datasets Dalia C. Kahane, Westat, Rockville, MD ABSTRACT This paper demonstrates important features of combining datasets in SAS. The facility to

More information

Paper TU_09. Proc SQL Tips and Techniques - How to get the most out of your queries

Paper TU_09. Proc SQL Tips and Techniques - How to get the most out of your queries Paper TU_09 Proc SQL Tips and Techniques - How to get the most out of your queries Kevin McGowan, Constella Group, Durham, NC Brian Spruell, Constella Group, Durham, NC Abstract: Proc SQL is a powerful

More information

SAS PASSTHRU to Microsoft SQL Server using ODBC Nina L. Werner, Madison, WI

SAS PASSTHRU to Microsoft SQL Server using ODBC Nina L. Werner, Madison, WI Paper SA-03-2014 SAS PASSTHRU to Microsoft SQL Server using ODBC Nina L. Werner, Madison, WI ABSTRACT I wish I could live in SAS World I do much of my data analysis there. However, my current environment

More information

COMP 5138 Relational Database Management Systems. Week 5 : Basic SQL. Today s Agenda. Overview. Basic SQL Queries. Joins Queries

COMP 5138 Relational Database Management Systems. Week 5 : Basic SQL. Today s Agenda. Overview. Basic SQL Queries. Joins Queries COMP 5138 Relational Database Management Systems Week 5 : Basic COMP5138 "Relational Database Managment Systems" J. Davis 2006 5-1 Today s Agenda Overview Basic Queries Joins Queries Aggregate Functions

More information

Information Systems SQL. Nikolaj Popov

Information Systems SQL. Nikolaj Popov Information Systems SQL Nikolaj Popov Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria popov@risc.uni-linz.ac.at Outline SQL Table Creation Populating and Modifying

More information

Table Lookup: Techniques Beyond the Obvious Nancy Croonen, CC Training Services, Belgium ir. Henri Theuwissen, SOLID Partners, Belgium

Table Lookup: Techniques Beyond the Obvious Nancy Croonen, CC Training Services, Belgium ir. Henri Theuwissen, SOLID Partners, Belgium Paper 11-27 Table Lookup: Techniques Beyond the Obvious Nancy Croonen, CC Training Services, Belgium ir. Henri Theuwissen, SOLID Partners, Belgium ABSTRACT Table lookup operations are often the most time

More information

ICAB4136B Use structured query language to create database structures and manipulate data

ICAB4136B Use structured query language to create database structures and manipulate data ICAB4136B Use structured query language to create database structures and manipulate data Release: 1 ICAB4136B Use structured query language to create database structures and manipulate data Modification

More information

# or ## - how to reference SQL server temporary tables? Xiaoqiang Wang, CHERP, Pittsburgh, PA

# or ## - how to reference SQL server temporary tables? Xiaoqiang Wang, CHERP, Pittsburgh, PA # or ## - how to reference SQL server temporary tables? Xiaoqiang Wang, CHERP, Pittsburgh, PA ABSTRACT This paper introduces the ways of creating temporary tables in SQL Server, also uses some examples

More information

Using SQL Queries to Insert, Update, Delete, and View Data: Joining Multiple Tables. Lesson C Objectives. Joining Multiple Tables

Using SQL Queries to Insert, Update, Delete, and View Data: Joining Multiple Tables. Lesson C Objectives. Joining Multiple Tables Using SQL Queries to Insert, Update, Delete, and View Data: Joining Multiple Tables Wednesay 9/24/2014 Abdou Illia MIS 4200 - Fall 2014 Lesson C Objectives After completing this lesson, you should be able

More information

Top Ten Reasons to Use PROC SQL

Top Ten Reasons to Use PROC SQL Paper 042-29 Top Ten Reasons to Use PROC SQL Weiming Hu, Center for Health Research Kaiser Permanente, Portland, Oregon, USA ABSTRACT Among SAS users, it seems there are two groups of people, those who

More information

Chapter 1 Overview of the SQL Procedure

Chapter 1 Overview of the SQL Procedure Chapter 1 Overview of the SQL Procedure 1.1 Features of PROC SQL...1-3 1.2 Selecting Columns and Rows...1-6 1.3 Presenting and Summarizing Data...1-17 1.4 Joining Tables...1-27 1-2 Chapter 1 Overview of

More information

1 Structured Query Language: Again. 2 Joining Tables

1 Structured Query Language: Again. 2 Joining Tables 1 Structured Query Language: Again So far we ve only seen the basic features of SQL. More often than not, you can get away with just using the basic SELECT, INSERT, UPDATE, or DELETE statements. Sometimes

More information

Demystifying PROC SQL Join Algorithms Kirk Paul Lafler, Software Intelligence Corporation

Demystifying PROC SQL Join Algorithms Kirk Paul Lafler, Software Intelligence Corporation Paper TU01 Demystifying PROC SQL Join Algorithms Kirk Paul Lafler, Software Intelligence Corporation ABSTRACT When it comes to performing PROC SQL joins, users supply the names of the tables for joining

More information

SAS Online Course - Smart Mind Online Training, Hyderabad. SAS Online Training Course Content

SAS Online Course - Smart Mind Online Training, Hyderabad. SAS Online Training Course Content Faculty: Real time and certified SAS Online Training Course Content (Includes theoretical as well as practical sessions) BASICS BEFORE STARTING SAS: DATAWAREHOSING Concepts What is ETL ETL Concepts What

More information

Database Design and Programming with SQL: Part 2 Learning Objectives

Database Design and Programming with SQL: Part 2 Learning Objectives Database Design and Programming with SQL: Part 2 Learning Objectives This is the second portion of the Database Design and Programming with SQL course. In this portion, students implement their database

More information

D61830GC30. MySQL for Developers. Summary. Introduction. Prerequisites. At Course completion After completing this course, students will be able to:

D61830GC30. MySQL for Developers. Summary. Introduction. Prerequisites. At Course completion After completing this course, students will be able to: D61830GC30 for Developers Summary Duration Vendor Audience 5 Days Oracle Database Administrators, Developers, Web Administrators Level Technology Professional Oracle 5.6 Delivery Method Instructor-led

More information

Using Proc SQL and ODBC to Manage Data outside of SAS Jeff Magouirk, National Jewish Medical and Research Center, Denver, Colorado

Using Proc SQL and ODBC to Manage Data outside of SAS Jeff Magouirk, National Jewish Medical and Research Center, Denver, Colorado Using Proc SQL and ODBC to Manage Data outside of SAS Jeff Magouirk, National Jewish Medical and Research Center, Denver, Colorado ABSTRACT The ability to use Proc SQL and ODBC to manage data outside of

More information

Paper 109-25 Merges and Joins Timothy J Harrington, Trilogy Consulting Corporation

Paper 109-25 Merges and Joins Timothy J Harrington, Trilogy Consulting Corporation Paper 109-25 Merges and Joins Timothy J Harrington, Trilogy Consulting Corporation Abstract This paper discusses methods of joining SAS data sets. The different methods and the reasons for choosing a particular

More information

Advanced Query for Query Developers

Advanced Query for Query Developers for Developers This is a training guide to step you through the advanced functions of in NUFinancials. is an ad-hoc reporting tool that allows you to retrieve data that is stored in the NUFinancials application.

More information

SQL Pass-Through and the ODBC Interface

SQL Pass-Through and the ODBC Interface SQL Pass-Through and the ODBC Interface Jessica Hampton, CIGNA Corporation, Bloomfield, CT ABSTRACT Does SAS implicit SQL pass-through sometimes fail to meet your needs? Do you sometimes need to communicate

More information

Performing Queries Using PROC SQL (1)

Performing Queries Using PROC SQL (1) SAS SQL Contents Performing queries using PROC SQL Performing advanced queries using PROC SQL Combining tables horizontally using PROC SQL Combining tables vertically using PROC SQL 2 Performing Queries

More information

From Database to your Desktop: How to almost completely automate reports in SAS, with the power of Proc SQL

From Database to your Desktop: How to almost completely automate reports in SAS, with the power of Proc SQL From Database to your Desktop: How to almost completely automate reports in SAS, with the power of Proc SQL Kirtiraj Mohanty, Department of Mathematics and Statistics, San Diego State University, San Diego,

More information

Course 20461C: Querying Microsoft SQL Server Duration: 35 hours

Course 20461C: Querying Microsoft SQL Server Duration: 35 hours Course 20461C: Querying Microsoft SQL Server Duration: 35 hours About this Course This course is the foundation for all SQL Server-related disciplines; namely, Database Administration, Database Development

More information

SQL Server. 2012 for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach

SQL Server. 2012 for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach TRAINING & REFERENCE murach's SQL Server 2012 for developers Bryan Syverson Joel Murach Mike Murach & Associates, Inc. 4340 N. Knoll Ave. Fresno, CA 93722 www.murach.com murachbooks@murach.com Expanded

More information

SQL SELECT Query: Intermediate

SQL SELECT Query: Intermediate SQL SELECT Query: Intermediate IT 4153 Advanced Database J.G. Zheng Spring 2012 Overview SQL Select Expression Alias revisit Aggregate functions - complete Table join - complete Sub-query in where Limiting

More information

A Comparison of Database Query Languages: SQL, SPARQL, CQL, DMX

A Comparison of Database Query Languages: SQL, SPARQL, CQL, DMX ISSN: 2393-8528 Contents lists available at www.ijicse.in International Journal of Innovative Computer Science & Engineering Volume 3 Issue 2; March-April-2016; Page No. 09-13 A Comparison of Database

More information

Course ID#: 1401-801-14-W 35 Hrs. Course Content

Course ID#: 1401-801-14-W 35 Hrs. Course Content Course Content Course Description: This 5-day instructor led course provides students with the technical skills required to write basic Transact- SQL queries for Microsoft SQL Server 2014. This course

More information

Querying Microsoft SQL Server 2012

Querying Microsoft SQL Server 2012 Course 10774A: Querying Microsoft SQL Server 2012 Length: 5 Days Language(s): English Audience(s): IT Professionals Level: 200 Technology: Microsoft SQL Server 2012 Type: Course Delivery Method: Instructor-led

More information

USING SAS WITH ORACLE PRODUCTS FOR DATABASE MANAGEMENT AND REPORTING

USING SAS WITH ORACLE PRODUCTS FOR DATABASE MANAGEMENT AND REPORTING USING SAS WITH ORACLE PRODUCTS FOR DATABASE MANAGEMENT AND REPORTING Henry W. Buffum, R. O. W. ScIences, Inc. Darryl J. Keith, U.S. Environmental Protection Agency Abstract: Data for a large environmental

More information

Querying Microsoft SQL Server 20461C; 5 days

Querying Microsoft SQL Server 20461C; 5 days Lincoln Land Community College Capital City Training Center 130 West Mason Springfield, IL 62702 217-782-7436 www.llcc.edu/cctc Querying Microsoft SQL Server 20461C; 5 days Course Description This 5-day

More information

Calculating Changes and Differences Using PROC SQL With Clinical Data Examples

Calculating Changes and Differences Using PROC SQL With Clinical Data Examples Calculating Changes and Differences Using PROC SQL With Clinical Data Examples Chang Y. Chung, Princeton University, Princeton, NJ Lei Zhang, Celgene Corporation, Summit, NJ ABSTRACT It is very common

More information

Querying Microsoft SQL Server

Querying Microsoft SQL Server Course 20461C: Querying Microsoft SQL Server Module 1: Introduction to Microsoft SQL Server 2014 This module introduces the SQL Server platform and major tools. It discusses editions, versions, tools used

More information

Course 10774A: Querying Microsoft SQL Server 2012

Course 10774A: Querying Microsoft SQL Server 2012 Course 10774A: Querying Microsoft SQL Server 2012 About this Course This 5-day instructor led course provides students with the technical skills required to write basic Transact-SQL queries for Microsoft

More information

Course 10774A: Querying Microsoft SQL Server 2012 Length: 5 Days Published: May 25, 2012 Language(s): English Audience(s): IT Professionals

Course 10774A: Querying Microsoft SQL Server 2012 Length: 5 Days Published: May 25, 2012 Language(s): English Audience(s): IT Professionals Course 10774A: Querying Microsoft SQL Server 2012 Length: 5 Days Published: May 25, 2012 Language(s): English Audience(s): IT Professionals Overview About this Course Level: 200 Technology: Microsoft SQL

More information

Financial Data Access with SQL, Excel & VBA

Financial Data Access with SQL, Excel & VBA Computational Finance and Risk Management Financial Data Access with SQL, Excel & VBA Guy Yollin Instructor, Applied Mathematics University of Washington Guy Yollin (Copyright 2012) Data Access with SQL,

More information

Introducing Microsoft SQL Server 2012 Getting Started with SQL Server Management Studio

Introducing Microsoft SQL Server 2012 Getting Started with SQL Server Management Studio Querying Microsoft SQL Server 2012 Microsoft Course 10774 This 5-day instructor led course provides students with the technical skills required to write basic Transact-SQL queries for Microsoft SQL Server

More information

CODERS CORNER ABSTRACT INTRODUCTION CREATING TABLES SUB-SETTING TABLES

CODERS CORNER ABSTRACT INTRODUCTION CREATING TABLES SUB-SETTING TABLES ABSTRACT CODERS CORNER SQL vs SAS : Clash of the Titans Rick Andrews, Office of Research, Development, and Information, Baltimore, MD Tom Kress, Center for Medicaid and State Operations, Baltimore, MD

More information

Introduction to SQL and SQL in R. LISA Short Courses Xinran Hu

Introduction to SQL and SQL in R. LISA Short Courses Xinran Hu Introduction to SQL and SQL in R LISA Short Courses Xinran Hu 1 Laboratory for Interdisciplinary Statistical Analysis LISA helps VT researchers benefit from the use of Statistics Collaboration: Visit our

More information

Developing an On-Demand Web Report Platform Using Stored Processes and SAS Web Application Server

Developing an On-Demand Web Report Platform Using Stored Processes and SAS Web Application Server Paper 10740-2016 Developing an On-Demand Web Report Platform Using Stored Processes and SAS Web Application Server ABSTRACT Romain Miralles, Genomic Health. As SAS programmers, we often develop listings,

More information

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 Outline More Complex SQL Retrieval Queries

More information

Soma Ghosh, UnitedHealth Group, Minneapolis, MN

Soma Ghosh, UnitedHealth Group, Minneapolis, MN Paper BB-13-2014 Some useful SQL Procedures in SAS Applications in complex scenarios Soma Ghosh, UnitedHealth Group, Minneapolis, MN ABSTRACT SQL Procedure (PROC SQL) is a very powerful feature provided

More information

Handling Missing Values in the SQL Procedure

Handling Missing Values in the SQL Procedure Handling Missing Values in the SQL Procedure Danbo Yi, Abt Associates Inc., Cambridge, MA Lei Zhang, Domain Solutions Corp., Cambridge, MA ABSTRACT PROC SQL as a powerful database management tool provides

More information

IT2305 Database Systems I (Compulsory)

IT2305 Database Systems I (Compulsory) Database Systems I (Compulsory) INTRODUCTION This is one of the 4 modules designed for Semester 2 of Bachelor of Information Technology Degree program. CREDITS: 04 LEARNING OUTCOMES On completion of this

More information

WORKING WITH SUBQUERY IN THE SQL PROCEDURE

WORKING WITH SUBQUERY IN THE SQL PROCEDURE WORKING WITH SUBQUERY IN THE SQL PROCEDURE Lei Zhang, Domain Solutions Corp., Cambridge, MA Danbo Yi, Abt Associates, Cambridge, MA ABSTRACT Proc SQL is a major contribution to the SAS /BASE system. One

More information

SAS Clinical Training

SAS Clinical Training Course Outline for SAS Clinical Training SAS Clinical Training SAS Clinical Introduction History of SAS SAS comes in ERP sector or not? Why? Role of Statistical Analysis in Clinical Research Study and

More information

MySQL for Beginners Ed 3

MySQL for Beginners Ed 3 Oracle University Contact Us: 1.800.529.0165 MySQL for Beginners Ed 3 Duration: 4 Days What you will learn The MySQL for Beginners course helps you learn about the world's most popular open source database.

More information

Instant SQL Programming

Instant SQL Programming Instant SQL Programming Joe Celko Wrox Press Ltd. INSTANT Table of Contents Introduction 1 What Can SQL Do for Me? 2 Who Should Use This Book? 2 How To Use This Book 3 What You Should Know 3 Conventions

More information

SQL Query & Modification

SQL Query & Modification CS145 Lecture Notes #7 SQL Query & Modification Introduction SQL Structured Query Language Pronounced S-Q-L or sequel The query language of every commercial RDBMS Evolution of SQL standard: SQL89 SQL92

More information

SQL Boot Camp. End To End SQL Query Writing, Database Design & Development Training. SQL Boot Camp Training.

SQL Boot Camp. End To End SQL Query Writing, Database Design & Development Training. SQL Boot Camp Training. Page 1 of 7 SQL Boot Camp www.sqlbootcamp.com End To End SQL Query Writing, Database Design & Development Training Database Design Query Optimization SQL Boot Camp Training Database Development SQL Query

More information

Welcome to the topic on queries in SAP Business One.

Welcome to the topic on queries in SAP Business One. Welcome to the topic on queries in SAP Business One. 1 In this topic, you will learn to create SQL queries using the SAP Business One query tools Query Wizard and Query Generator. You will also see how

More information

Using SAS Enterprise Business Intelligence to Automate a Manual Process: A Case Study Erik S. Larsen, Independent Consultant, Charleston, SC

Using SAS Enterprise Business Intelligence to Automate a Manual Process: A Case Study Erik S. Larsen, Independent Consultant, Charleston, SC Using SAS Enterprise Business Intelligence to Automate a Manual Process: A Case Study Erik S. Larsen, Independent Consultant, Charleston, SC Abstract: Often times while on a client site as a SAS consultant,

More information

PROC SQL for SQL Die-hards Jessica Bennett, Advance America, Spartanburg, SC Barbara Ross, Flexshopper LLC, Boca Raton, FL

PROC SQL for SQL Die-hards Jessica Bennett, Advance America, Spartanburg, SC Barbara Ross, Flexshopper LLC, Boca Raton, FL PharmaSUG 2015 - Paper QT06 PROC SQL for SQL Die-hards Jessica Bennett, Advance America, Spartanburg, SC Barbara Ross, Flexshopper LLC, Boca Raton, FL ABSTRACT Inspired by Christianna William s paper on

More information

MOC 20461 QUERYING MICROSOFT SQL SERVER

MOC 20461 QUERYING MICROSOFT SQL SERVER ONE STEP AHEAD. MOC 20461 QUERYING MICROSOFT SQL SERVER Length: 5 days Level: 300 Technology: Microsoft SQL Server Delivery Method: Instructor-led (classroom) COURSE OUTLINE Module 1: Introduction to Microsoft

More information

AN INTRODUCTION TO THE SQL PROCEDURE Chris Yindra, C. Y. Associates

AN INTRODUCTION TO THE SQL PROCEDURE Chris Yindra, C. Y. Associates AN INTRODUCTION TO THE SQL PROCEDURE Chris Yindra, C Y Associates Abstract This tutorial will introduce the SQL (Structured Query Language) procedure through a series of simple examples We will initially

More information

Displaying Data from Multiple Tables

Displaying Data from Multiple Tables 4 Displaying Data from Multiple Tables Copyright Oracle Corporation, 2001. All rights reserved. Schedule: Timing Topic 55 minutes Lecture 55 minutes Practice 110 minutes Total Objectives After completing

More information

Querying Microsoft SQL Server (20461) H8N61S

Querying Microsoft SQL Server (20461) H8N61S HP Education Services course data sheet Querying Microsoft SQL Server (20461) H8N61S Course Overview In this course, you will learn the technical skills required to write basic Transact-SQL (T-SQL) queries

More information

Improving Maintenance and Performance of SQL queries

Improving Maintenance and Performance of SQL queries PaperCC06 Improving Maintenance and Performance of SQL queries Bas van Bakel, OCS Consulting, Rosmalen, The Netherlands Rick Pagie, OCS Consulting, Rosmalen, The Netherlands ABSTRACT Almost all programmers

More information

Choosing the Best Method to Create an Excel Report Romain Miralles, Clinovo, Sunnyvale, CA

Choosing the Best Method to Create an Excel Report Romain Miralles, Clinovo, Sunnyvale, CA Choosing the Best Method to Create an Excel Report Romain Miralles, Clinovo, Sunnyvale, CA ABSTRACT PROC EXPORT, LIBNAME, DDE or excelxp tagset? Many techniques exist to create an excel file using SAS.

More information

2071B Querying Microsoft SQL Server 2000 with Transact-SQL

2071B Querying Microsoft SQL Server 2000 with Transact-SQL Course: 2071B Querying Microsoft SQL Server 2000 with Transact-SQL Description: The goal of this course is to provide students with the technical skills required to write basic Transact-SQL queries for

More information

Querying Microsoft SQL Server Course M20461 5 Day(s) 30:00 Hours

Querying Microsoft SQL Server Course M20461 5 Day(s) 30:00 Hours Área de formação Plataforma e Tecnologias de Informação Querying Microsoft SQL Introduction This 5-day instructor led course provides students with the technical skills required to write basic Transact-SQL

More information

DATA Step vs. PROC SQL: What s a neophyte to do?

DATA Step vs. PROC SQL: What s a neophyte to do? Paper 269-29 DATA Step vs. What s a neophyte to do? Craig Dickstein, Tamarack Professional Services, Jackman, ME Ray Pass, Ray Pass Consulting, Hartsdale, NY ABSTRACT "What's all the buzz about Proc SQL?

More information

GROUP BY and HAVING. SELECT MIN (S.age) FROM Sailors S WHERE S.rating = i. For i = 1, 2,..., 10:

GROUP BY and HAVING. SELECT MIN (S.age) FROM Sailors S WHERE S.rating = i. For i = 1, 2,..., 10: SQL - 4 Week 9 GROUP BY and HAVING So far, we ve applied aggregate operators to all (qualifying) tuples. Sometimes, we want to apply them to each of several groups of tuples. Consider: Find the age of

More information

Nutech Computer Training Institute 1682 E. Gude Dr. #102, Rockville, MD Tel: Website:

Nutech Computer Training Institute 1682 E. Gude Dr. #102, Rockville, MD Tel: Website: Nutech Computer Training Institute 1682 E. Gude Dr. #102, Rockville, MD. 20850 Tel:301-610-9300 Website: www.nutechtraining.com SAS Hands-On Programming Training Outline Total Hours: 96 hrs Package Tuition

More information

Relational Algebra The Relational Algebra and Relational Calculus. Relational Query Languages

Relational Algebra The Relational Algebra and Relational Calculus. Relational Query Languages The Relational Algebra and Relational Calculus Relational Algebra Slide 6-2 Relational Query Languages Query languages Allow manipulation and retrieval of data Not like programming languages Not intend

More information

Five Little Known, But Highly Valuable, PROC SQL Programming Techniques. a presentation by Kirk Paul Lafler

Five Little Known, But Highly Valuable, PROC SQL Programming Techniques. a presentation by Kirk Paul Lafler Five Little Known, But Highly Valuable, PROC SQL Programming Techniques a presentation by Kirk Paul Lafler Copyright 1992-2014 by Kirk Paul Lafler and Software Intelligence Corporation. All rights reserved.

More information

Toad for Data Analysts, Tips n Tricks

Toad for Data Analysts, Tips n Tricks Toad for Data Analysts, Tips n Tricks or Things Everyone Should Know about TDA Just what is Toad for Data Analysts? Toad is a brand at Quest. We have several tools that have been built explicitly for developers

More information

Paper PO03. A Case of Online Data Processing and Statistical Analysis via SAS/IntrNet. Sijian Zhang University of Alabama at Birmingham

Paper PO03. A Case of Online Data Processing and Statistical Analysis via SAS/IntrNet. Sijian Zhang University of Alabama at Birmingham Paper PO03 A Case of Online Data Processing and Statistical Analysis via SAS/IntrNet Sijian Zhang University of Alabama at Birmingham BACKGROUND It is common to see that statisticians at the statistical

More information

Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle Database: SQL and PL/SQL Fundamentals NEW Oracle University Contact Us: 001-855-844-3881 & 001-800-514-06-97 Oracle Database: SQL and PL/SQL Fundamentals NEW Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals

More information

Chapter 5. SQL: Queries, Constraints, Triggers

Chapter 5. SQL: Queries, Constraints, Triggers Chapter 5 SQL: Queries, Constraints, Triggers 1 Overview: aspects of SQL DML: Data Management Language. Pose queries (Ch. 5) and insert, delete, modify rows (Ch. 3) DDL: Data Definition Language. Creation,

More information

Introduction to Microsoft Jet SQL

Introduction to Microsoft Jet SQL Introduction to Microsoft Jet SQL Microsoft Jet SQL is a relational database language based on the SQL 1989 standard of the American Standards Institute (ANSI). Microsoft Jet SQL contains two kinds of

More information

Unit 3. Retrieving Data from Multiple Tables

Unit 3. Retrieving Data from Multiple Tables Unit 3. Retrieving Data from Multiple Tables What This Unit Is About How to retrieve columns from more than one table or view. What You Should Be Able to Do Retrieve data from more than one table or view.

More information

A basic create statement for a simple student table would look like the following.

A basic create statement for a simple student table would look like the following. Creating Tables A basic create statement for a simple student table would look like the following. create table Student (SID varchar(10), FirstName varchar(30), LastName varchar(30), EmailAddress varchar(30));

More information

Implementing Table Operations Using Structured Query Language (SQL) Remember Operations On Tables The ability to construct tables from other tables.

Implementing Table Operations Using Structured Query Language (SQL) Remember Operations On Tables The ability to construct tables from other tables. Implementing Table Operations Using Structured Query Language (SQL) The implementation of table operations in relational database management systems is done through use of SQL, or Structured Query Language,

More information

Oracle Database: Introduction to SQL

Oracle Database: Introduction to SQL Oracle University Contact Us: +381 11 2016811 Oracle Database: Introduction to SQL Duration: 5 Days What you will learn Understanding the basic concepts of relational databases ensure refined code by developers.

More information

Accessing Your Database with JMP 10 JMP Discovery Conference 2012 Brian Corcoran SAS Institute

Accessing Your Database with JMP 10 JMP Discovery Conference 2012 Brian Corcoran SAS Institute Accessing Your Database with JMP 10 JMP Discovery Conference 2012 Brian Corcoran SAS Institute JMP provides a variety of mechanisms for interfacing to other products and getting data into JMP. The connection

More information

Statistics and Analysis. Quality Control: How to Analyze and Verify Financial Data

Statistics and Analysis. Quality Control: How to Analyze and Verify Financial Data Abstract Quality Control: How to Analyze and Verify Financial Data Michelle Duan, Wharton Research Data Services, Philadelphia, PA As SAS programmers dealing with massive financial data from a variety

More information

Alternatives to Merging SAS Data Sets But Be Careful

Alternatives to Merging SAS Data Sets But Be Careful lternatives to Merging SS Data Sets ut e Careful Michael J. Wieczkowski, IMS HELTH, Plymouth Meeting, P bstract The MERGE statement in the SS programming language is a very useful tool in combining or

More information

Web Development using PHP (WD_PHP) Duration 1.5 months

Web Development using PHP (WD_PHP) Duration 1.5 months Duration 1.5 months Our program is a practical knowledge oriented program aimed at learning the techniques of web development using PHP, HTML, CSS & JavaScript. It has some unique features which are as

More information