Sas Table Joins Tutorial

  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Sas Table Joins Tutorial as PDF for free.

More details

  • Words: 260
  • Pages: 2
SAS Table Joins Tutorial & Demonstrations – Tom Tuduc Inner Join, Right Join, Left Join, and Full Join. This tutorial demonstrates various table joins in SAS with SQL codes and results. Sample Data Table Measurement PersonId 1 3 4 5 6

Weight 133 123 98 155 158

Table Patient PersonId Name 1 Mike J. 2 Ann K. 3 Trish L. 7 Tom K 9 Lance T.

Height 5.7 5.4 5.5 5.9 6.1

Gender m f f m m

City Portland Salem Eugene Portland Portland

INNER JOIN

proc sql; select Patient.PersonID, Height, Name, Gender from Measurement, Patient where Measurement.PersonId = Patient.PersonId; quit;

Results: PersonId 1 3

Height 5.7 5.4

Name Mike J. Trish L.

Gender m f

RIGHT JOIN, LEFT JOIN, and FULL JOIN proc sql; title " Performing Right Join"; select p.PersonId as Patient_PersonId , m.PersonId as Measurement_PersonId, Height from learn.Patient as p right join learn.Measurement as m on p.PersonId eq m.PersonId; title " Performing Left Join";

select p.PersonId as Patient_PersonId , m.PersonId as Measurement_PersonId, Height from learn.Patient as p left join learn.Measurement as m on p.PersonId eq m.PersonId; title " Performing Full Join"; select p.PersonId as Patient_PersonId , m.PersonId as Measurement_PersonId, Height from learn.Patient as p full join learn.Measurement as m on p.PersonId eq m.PersonId; quit;

Results: Performing Right Join Patient_PersonId

Measurement_PersonId

Height

1 3 4 5 6

1 3

5.7 5.4 5.5 5.9 6.1

Patient_PersonId

Measurement_PersonId

Height

1

1 2 3 7 9

5.7

Measurement_PersonId

Height

Performing Left Join

3

5.4

Performing Full Join Patient_PersonId

1

5.7 2

3 4 5 6

5.4 5.5 5.9 6.1 7 9

Related Documents

Sas Table Joins Tutorial
October 2019 6
Tutorial: Joins In Mysql
October 2019 20
Joins
May 2020 14
Joins
November 2019 16
Joins
November 2019 23
Ofhs Tutorial Sas (1)
June 2020 4