Lecture12 - Chapter 21: Combining SAS Data Sets 21.1 Using...

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

View Full Document Right Arrow Icon
1 Chapter 21: Combining SAS Data Sets 21.1 Using Data Manipulation Techniques with Match-Merging
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Objectives Use data manipulation techniques in a DATA step to perform a match-merge. Perform a match-merge on three SAS data sets that lack a common variable. Perform a match-merge on a SAS data set and an Excel worksheet. Perform a match-merge on SAS data sets that have identically named variables other than the BY variables.
Background image of page 2
3 Match-Merging (Review) Match-merging combines observations from one or more SAS data sets into a single observation in a new data set based on the values of one or more common variables. proc sort data=orion.order_fact out=work.order_fact; by Customer_ID; where year(Order_Date)=2007; run; data CustOrd; merge orion.customer work.order_fact; run; Customers of Orion Star Products ordered by Orion Star customers in year 2007
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Multiple Choice Poll Which statement is true concerning match-merging? a. The MERGE statement must refer to permanent data sets. b. The variables in the BY statement can only be in one of the data sets. c. Only two data sets can be specified in the MERGE statement. d. When you use the MERGE statement with the BY statement, the data must be sorted or indexed on the BY variable.
Background image of page 4
5 Multiple Choice Poll Correct Answer Which statement is true concerning match-merging? a. The MERGE statement must refer to permanent data sets. b. The variables in the BY statement can only be in one of the data sets. c. Only two data sets can be specified in the MERGE statement. d. When you use the MERGE statement with the BY statement, the data must be sorted or indexed on the BY variable.
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Match-Merging (Review) Partial SAS Log The output data set contains both matches and non-matches, therefore, it has more observations than either input data set. 729 proc sort data=orion.order_fact 730 out=work.order_fact; 731 by Customer_ID; 732 where year(Order_Date)=2007; 733 run; NOTE: There were 148 observations read from the data set ORION.ORDER_FACT. WHERE YEAR(Order_Date)=2007; NOTE: The data set WORK.ORDER_FACT has 148 observations and 12 variables. 734 735 data CustOrd; 736 merge orion.customer 737 work.order_fact; 738 by Customer_ID; 739 run; NOTE: There were 77 observations read from the data set ORION.CUSTOMER. NOTE: There were 148 observations read from the data set WORK.ORDER_FACT. NOTE: The data set WORK.CUSTORD has 188 observations and 22 variables.
Background image of page 6
7 Match-Merging (Review) By default, match-merging produces matches and non-matches. Partial PROC PRINT Output: The highlighted text represents the matches, which means that both data sets contributed to these observations. Total_Retail_ Obs Customer_Name Gender Quantity Price 160 Bill Cuddy M . . 161 Avinoam Zweig M . . 164 Eyal Bloch M . .
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Multiple Choice Poll Which of the following data set options can be added to the MERGE statement to help identify matches?
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 107

Lecture12 - Chapter 21: Combining SAS Data Sets 21.1 Using...

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

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