Lesson 10: Combining SAS Data Sets

Ace your homework & exams now with Quizwiz!

missing

If you concatenate the data sets below in the order shown, what is the value of Sale in observation 2 of the new data set? reps ID Name 1 Nay Rong 2 Kelly Windsor 3 Julio Meraz 4 Richard Krabill close ID Sale 1 $28,000 2 $30,000 2 $40,000 3 $15,000 3 $20,000 3 $25,000 4 $35,000

all observations from staff and all observations from managers, whether or not they have matching values

If you run this DATA step, what observations does the data set bonuses contain? data bonuses; merge managers staff; by EmpID; run;

only the observations from staff that have no match in managers

If you run this DATA step, what observations does the data set bonuses contain? data bonuses; merge managers (in=M) staff (in=S); by EmpID; if M=0 and S=1; run;

C=1, A=1

In the second iteration of this DATA step, after the data is merged, what are the values of C and A? data client_amount; merge clients(in=C) amounts(in=A); by Name; run; clients Name EmpID Ankerton 11123 Davis 22293 Masters 33351 Wolmer 44483 amounts Name Date Amt Ankerton 08OCT96 92 Ankerton 15OCT96 43 Davis 04OCT96 16 Masters . 27 Thomas 21OCT96 15

data widgets_all; set widget1 widget2(rename=(Hue=Color)); run;

Suppose you want to concatenate these data sets. Which DATA step creates an output data set that combines the values of Color and Hue in the single variable Color? widget1 Tag Color Model 77904 blue AB42 56012 red BA25 35499 orange FC36 widget2 Tag Hue Model 89325 red SP17 65888 yellow BA12 00167 green PG20 a. data widgets_all; set widget1(rename=(Color=Hue)) widget2; run; b. data widgets_all; set widget1 widget2(rename=(Hue=Color)); run; c. data widgets_all; set widget1 widget2(Hue=color); run;

The DATA step produces errors.

What happens if you submit the following program to merge donors1 and donors2, shown below? data merged; merge donors1 donors2; by ID; run; donors1 ID Type Units 2304 O 16 1129 A 48 1129 A 50 1129 A 57 2486 B 63 donors2 ID Code Units 6488 65 27 1129 63 32 5438 62 39 2304 61 45 1387 64 67

one-to-one

What is the relationship of the data set first to the data set second when merged by the variable ID? first Name ID Age Togar 121150 39 Kylie 121152 34 Birin 121153 32 Gloria 121154 12 James 121155 36 Gene 121156 28 Tom 121157 27 second ID Date 121150 02/15/05 121152 05/22/07 121153 03/04/06 121154 11/22/05 121155 07/08/06 121156 12/15/06 121157 04/30/07

There are too many sets of parentheses in the RENAME= option.

What is the syntax error in this DATA step? data returns_qtr1; set returns_jan(rename=(ID=CustID) (Return=Item)) returns_feb(rename=(Dt=Date)) returns_mar; run;

data newsales; set sales products; run;

Which of the following programs concatenates the data sets, sales and products, in that order? a. data newsales; set products sales; run; b. data newsales; set sales products; run; c. data newsales; set sales; set products; run;

All of the above

Which of the following statements is true about merging SAS data sets by using the DATA step? a. Merging combines observations from two or more data sets into a single observation in a new data set. b. SAS can merge data sets based on the position of observations in the original data set or by the values of one or more common variables. c. Match-merging is merging by values of one or more common variables. d. To match-merge data sets, all input data sets must be sorted or indexed on the BY variables. e. All of the above


Related study sets

Georgia Real Estate - Section 17 Unit 1

View Set

CH 30, Assessment of the Cardiovascular System

View Set