12.07.2015 Views

SPSS Programming and Data Management, 4th Edition: A Guide for ...

SPSS Programming and Data Management, 4th Edition: A Guide for ...

SPSS Programming and Data Management, 4th Edition: A Guide for ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

27Getting<strong>Data</strong>into<strong>SPSS</strong>• Left outer join. All records from the first table are included regardless of the criteriaused to match records.• Right outer join. Essentially the opposite of a left outer join. So, the appropriateone to use is basically a matter of the order in which the tables are specified in theSQL SELECT clause.ExampleIn the previous two examples, all of the data resided in a single database table. Butwhat if the data were divided between two tables? This example merges data from twodifferent tables: one containing demographic in<strong>for</strong>mation <strong>for</strong> survey respondents <strong>and</strong>one containing survey responses.*access_multtables1.sps.GET DATA /TYPE=ODBC /CONNECT='DSN=MS Access <strong>Data</strong>base;DBQ=C:\examples\data\dm_demo.mdb;'+'DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;'/SQL ='SELECT * FROM DemographicIn<strong>for</strong>mation, SurveyResponses'' WHERE DemographicIn<strong>for</strong>mation.ID=SurveyResponses.ID'.EXECUTE.• The SELECT clause specifies all fields from both tables.• The WHERE clause matches records from the two tables based on the value of theID field in both tables. Any records in either table without matching ID values inthe other table are excluded.• The result is an inner join in which only records with matching ID values in bothtables are included in the active dataset.ExampleIn addition to one-to-one matching, as in the previous inner join example, you can alsomerge tables with a one-to-many matching scheme. For example, you could match atable in which there are only a few records representing data values <strong>and</strong> associateddescriptive labels with values in a table containing hundreds or thous<strong>and</strong>s of recordsrepresenting survey respondents.In this example, we read data from an SQL Server database, using an outer join toavoid omitting records in the larger table that don’t have matching identifier values inthe smaller table.*sqlserver_outer_join.sps.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!