1 Lab 2 HRP223 – 2010 October 18, 2010 Copyright © 1999-2010 Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected.

Slides:



Advertisements
Similar presentations
Information Systems Technology Ross Malaga B Copyright © 2005 Prentice Hall, Inc. B-1 WORKING WITH DATABASES.
Advertisements

Database Basics. What is Access? Database management system Computer-based equivalent of a manual database Makes it easy to organize and update information.
What is a Database By: Cristian Dubon.
Oracle for Windows NT is required to run queries from the Banner database. Call the help desk at extension 4440 if you do not have this.
In Campus Pipeline use the My Class Rosters link appropriate for your computer and follow the directions to browse to your roster files. Copy and paste.
Final Thoughts HRP 223 – 2013 December 4 th, 2013 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation.
Working with Data in Windows HRP223 – 2010 October 4 th, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
1 SAS Formats and SAS Macro Language HRP223 – 2011 November 9 th, 2011 Copyright © Leland Stanford Junior University. All rights reserved. Warning:
Beginning Data Manipulation HRP Topic 4 Oct 19 th 2011.
1 Merging with SQL HRP223 – 2011 October 31, 2011 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation.
1 Processing Grouped Data HRP223 – 2011 November 14 th, 2011 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
1 Combining (with SQL) HRP223 – 2010 October 27, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation.
1 Creating and Tweaking Data HRP223 – 2010 October 24, 2011 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
1 Database Theory and Normalization HRP223 – 2010 November 14 th, 2011 Copyright © Leland Stanford Junior University. All rights reserved. Warning:
30-Jun-15 SQL A Brief Introduction. SQL SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell”
Microsoft Access 2010 Chapter 7 Using SQL.
SAS for Categorical Data Copyright © 2004 Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Copyright 2007, Paradigm Publishing Inc. BACKNEXTEND 3-1 LINKS TO OBJECTIVES Save a Filter as a Query Save a Filter as a Query Parameter Query Inner, Left,
1 MySQL and phpMyAdmin. 2 Navigate to and log on (username: pmadmin)
1 Data Manipulation (with SQL) HRP223 – 2010 October 13, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
HPR Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
Working with Data in Windows HRP223 – 2009 Sept 28 th, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
1 By: Nour Hilal. Microsoft Access is a database software where data is stored in one or more Tables. A Database is a group of related Tables. Access.
WEEK 11 Database Design. TABLE INSTANCE CHARTS Create Tables.
Relationships and Advanced Query Concepts Using Multiple Tables Please use speaker notes for additional information!
Chapter 17 Creating a Database.
Database Systems Microsoft Access Practical #3 Queries Nos 215.
HRP Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
1 Lab 2 and Merging Data (with SQL) HRP223 – 2009 October 19, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning:
Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and international.
1 Summary HRP223 – 2009 November 1 st, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is.
WHAT IS A DATABASE? A DATABASE IS A COLLECTION OF DATA RELATED TO A PARTICULAR TOPIC OR PURPOSE OR TO PUT IT SIMPLY A GENERAL PURPOSE CONTAINER FOR STORING.
1 Data Manipulation (with SQL) HRP223 – 2010 October 13, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
O FFICE M ANAGEMENT T OOL - II B BA -V I TH. Abdus Salam2 Week-7 Introduction to Query Introduction to Query Querying from Multiple Tables Querying from.
While you are waiting for class to start... (1) Login to SQL Server 2012 Management Studio (2) Execute the file called “SQLLab3.sql”. It is located on.
HRP Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
Advanced Adhoc Reporting 2010 Visions Conference July 28, 2010.
HRP Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
Merging Data into a Letter. Start with a letter that has places where you want to merge individual data ready to go.
1 Lab 1 HRP223 – 2011 Oct 10, 2011 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected.
Schoolnet Training Module 3 D. Tierney. Hover over Classrooms Click on Student Performance Click on tab Student Analysis Click on Advanced, create your.
Classwork: Common Errors Primary keys: don’t forget them! Primary keys: choose the best one! – “Name” and “birthday” are not the best choices. – “Phone.
HRP Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
HRP 223 – 2007 lm.ppt - Linear Models Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 5: SQL I Rob Gleasure robgleasure.com.
1 Data Manipulation (with SQL) HRP223 – 2009 October 12, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Chapter 18. Copyright 2003, Paradigm Publishing Inc. CHAPTER 18 BACKNEXTEND 18-2 LINKS TO OBJECTIVES Sort Text in Paragraphs, Columns, and Tables Sort.
Simple Queries DBS301 – Week 1. Objectives Basic SELECT statement Computed columns Aliases Concatenation operator Use of DISTINCT to eliminate duplicates.
Beginning Data Manipulation HRP Topic 4 Oct 14 th 2012 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
HRP Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and international.
Chapter 12 Introducing Databases. Objectives What a database is and which databases are typically used with ASP.NET pages What SQL is, how it looks, and.
Database application MySQL Database and PhpMyAdmin
Working with Data in Windows
SAS Output Delivery System
ISC440: Web Programming 2 Server-side Scripting PHP 3
Combining (with SQL) HRP223 – 2013 October 30, 2013
Combining Data Sets in the DATA step.
Lab 3 and HRP259 Lab and Combining (with SQL)
Lab 2 and Merging Data (with SQL)
Combining (with SQL) HRP223 – 2012 November 05, 2011
Lab 2 HRP223 – 2010 October 18, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected.
Query Functions.
A Bit About SAS/Macro Language Database Theory and Normalization
File Sharing and Processing Grouped Data
Data Manipulation (with SQL)
Processing Grouped Data
Presentation transcript:

1 Lab 2 HRP223 – 2010 October 18, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and international treaties. Unauthorized reproduction of this presentation, or any portion of it, may result in severe civil and criminal penalties and will be prosecuted to maximum extent possible under the law.

2 Topics How to join Tables – Inner joins – Left joins The coalesce() and coalescec() functions

3 Combining When you have data in two tables, you need to tell SQL how the two tables are related to each other. – Typically you have a subject ID number in both files. The variable that can be used to link information is called the key.

4 Demographics Response to Treatment Here the two tables have different variables (except ID) and they are in a different sort order. We want the favorite color merged in to see if it is related to response to treatment.

5 Merging Merging is trivially easy with EG. Choose a table and do the Query Builder…. And push the Join Tables button.

6 Double click on the dividing lines to make the columns wide enough to read.

7 Notice the name t1. In the SQL statements, variables from this table will have the prefix t1. This table will be referred to as t2. It noticed that the two tables have the common variable ID. Therefore it is going to match records that have a common value in ID. Double click the link for details.

8 Joins You will typically do inner joins and left joins. – Inner Joins: select the marching records – Left Joins: select all records on the left side and any records that match on the right.

9 Inner Joins Inner Joins are useful when you want to keep the information from the tables, if and only if, there are matches in both tables. – Here you keep the records where you have demographic and response to treatment information on people.

10 Left Joins Left joins are useful when you have a table with everybody on the left side of the join and not everyone has records in the right table. – A typical example has the left side with the IDs of everyone in a family and the right table has information on diagnoses. Not everyone is sick so you want to keep all the IDs on the left and add in diagnoses where you can.

11 Typical Left Join Notice the numeric variable is formatted to display with words.

12

13 Coalesce The previous example leaves NULL for the people who are disease free. You probably want to list the rest as healthy. The coalesce function returns the first non- missing value. – Coalesce works on numeric lists. – Coalesce works on character lists.

14

15 Coalesce If you are using left joins from multiple tables, coalesce can be really useful. – Say you have people who have reported disease, other people have verified disease and the rest are assumed to be healthy. You can coalesce an indicator variable from the verified table and reported table and call everybody else healthy.

16 If the tables have indicator variables, once the tables are linked, the coalesce function is easy: COALESCEC(t3.status2, t2.status1, "Healthy"))

17 No indicator variables? If the tables you are coalescing do not have indicator variables, just make them as part of the query by adding a column which has the ID in the child tables (e.g., reported and verified) recoded to a word like “reported” or “verified”.

18 The two new indicator columns.

19 Coalesce the new columns Once the new columns are created, create a new variable using the Advanced expression option for a new computed column. Then do coalesce on the new variables. Double click on the new variables and it will insert the code.

20 After double clicking the ver variable the code is inserted. Don’t forget the comma before double clicking the rep variable. After inserting reported and verified, put in another comma and the “healthy” option.

21