notes14 - 1 1 Notes 14: Other Merges Identifying Data Set...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 1 Notes 14: Other Merges Identifying Data Set Contributors 2 Other Merges In addition to one-to-one merges, the DATA step merge works with many other kinds of data combinations: one-to-many unique BY values are in one data set and duplicate matching BY values are in the other data set. many-to-many duplicate matching BY values are in both data sets. 3 work.two X Z 1 A1 1 A2 2 B1 3 C1 3 C2 work.one X Y Z 1 A A1 1 A A2 2 B B1 3 C C1 3 C C2 work.three data work.three; merge work.one work.two; by X; run; X Y 1 A 2 B 3 C One-to-Many Merging 4 Month Region Sales 1 Europe 2118222 1 North America 3135765 2 Europe 1960034 2 North America 2926929 allsales Month Goal 1 2127742 2 1920751 3 2125112 allgoals Month Region Sales Goal Difference 1 Europe 2118222 2127742 -9520 1 North America 3135765 2127742 1008023 2 Europe 1960034 1920751 39283 2 North America 2926929 1920751 1006178 allcompare data allcompare; merge allsales allgoals; by Month; Difference=Sales-Goal; run; One-to-Many Merging 5 work.three X Y 1 A1 1 A2 2 B1 2 B2 X Z 1 AA1 1 AA2 1 AA3 2 BB1 2 BB2 data work.three; merge work.one work.two; by X; run; X Y Z 1 A1 AA1 1 A2 AA2 1 A2 AA3 2 B1 BB1 2 B2 BB2 Many-to-Many Merging work.two work.one 6 Month Sales Goal Difference 1 2118222 2127742 -9520 1 3135765 2934441 201324 2 1960034 1920751 39283 2 2926929 2747787 179142 allcompare2 Month Goal 1 2127742 1 2934441 2 1920751 2 2747787 Month Sales 1 2118222 1 3135765 2 1960034 2 2926929 data allcompare2; merge allsales2 allgoals2; by Month; Difference=Sales-Goal; run; allsales2 Many-to-Many Merging allgoals2 2 7 Identifying Data Set Contributors When you read multiple SAS data sets in one DATA step, you can use the IN= data set option to detect which data set contributed to an observation. General form of the IN= data set option: where variable is any valid SAS variable name. SAS-data-set (IN= variable ) SAS-data-set (IN= variable ) 8 The IN= Data Set Option variable is a temporary numeric variable with a value of: 0 to indicate false; the data set did not contribute to the current observation 1 to indicate true; the data set did contribute to the current observation. 9 Using the IN= Data Set Option data newtrans noactiv (drop=Trans Amnt) noacct (drop=Branch); merge transact(in=InTrans) branches(in=InBanks); by ActNum; additional SAS statements run; 10 If the Observation Is a Match transact and branches both contributed to the observation. InTrans=1 and InBanks=1 Current Observation transact branches 11 If the Observation Is Not a Match branches contributed to the observation. transact did not. (The account had no transactions this week.) InTrans=0 and InBanks=1 Current Observation transact branches 12 If the Observation Is Not a Match transact contributed to the observation....
View Full Document

This note was uploaded on 10/31/2011 for the course STAT 440 taught by Professor Muyot,m during the Fall '08 term at University of Illinois, Urbana Champaign.

Page1 / 7

notes14 - 1 1 Notes 14: Other Merges Identifying Data Set...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online