13.07.2015 Views

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SHOW MORE
SHOW LESS

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

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

850 Reading Data from Multiple DBMS Tables 4 Chapter 29Reading Data from Multiple DBMS TablesYou can use the DATA step to read data from multiple data sets. This examplemerges data from the two Oracle tables Staff and SuperV in the <strong>SAS</strong> data setWork.Combined.libname mydblib oracle user=testuser password=testpass path=’@alias’;data combined;merge mydblib.staff mydblib.superv(in=superrename=(supid=idnum));by idnum;if super;run;proc print data=combined;title "Supervisor In<strong>for</strong>mation";run;Output 29.3Reading Data from Multiple DBMS TablesSupervisor In<strong>for</strong>mation 1Obs IDNUM LNAME FNAME CITY STATE HPHONE JOBCAT1 1106 MARSHBURN JASPER STAMFORD CT 203/781-1457 PT2 1118 DENNIS ROGER NEW YORK NY 718/383-1122 PT3 1126 KIMANI ANNE NEW YORK NY 212/586-1229 TA4 1352 RIVERS SIMON NEW YORK NY 718/383-3345 NA5 1385 RAYNOR MILTON BRIDGEPORT CT 203/675-2846 ME6 1401 ALVAREZ CARLOS PATERSON NJ 201/732-8787 TA7 1405 DACKO JASON PATERSON NJ 201/732-2323 SC8 1417 NEWKIRK WILLIAM PATERSON NJ 201/732-6611 NA9 1420 ROUSE JEREMY PATERSON NJ 201/732-9834 ME10 1431 YOUNG DEBORAH STAMFORD CT 203/781-2987 FA11 1433 YANCEY ROBIN PRINCETON NJ 201/812-1874 FA12 1442 NEWKIRK SANDRA PRINCETON NJ 201/812-3331 PT13 1564 WALTERS ANNE NEW YORK NY 212/587-3257 SC14 1639 CARTER-COHEN KAREN STAMFORD CT 203/781-8839 TA15 1677 KRAMER JACKSON BRIDGEPORT CT 203/675-7432 BC16 1834 LEBLANC RUSSELL NEW YORK NY 718/384-0040 BC17 1882 TUCKER ALAN NEW YORK NY 718/384-0216 ME18 1935 FERNANDEZ KATRINA BRIDGEPORT CT 203/675-2962 NA19 1983 DEAN SHARON NEW YORK NY 718/384-1647 FAUsing the DATA Step UPDATE Statement with DBMS DataYou can also use the DATA step UPDATE statement to create a <strong>SAS</strong> data set withDBMS data. This example creates the <strong>SAS</strong> data set Work.Payroll with data from theOracle tables Payroll and Payroll2. The Oracle tables are not modified.The columns in the two Oracle tables must match. However, Payroll2 can haveadditional columns. Any additional columns in Payroll2 are added to the Payroll dataset. The UPDATE statement requires unique values <strong>for</strong> IdNum to correctly merge thedata from Payroll2.

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

Saved successfully!

Ooh no, something went wrong!