**Question 14:The following SAS program is submitted:data work.empsalary;****set work.people (in = inemp)****work.money (in = insal);****if insal and inemp;**

run;

The SAS data set WORK.PEOPLE has 5 observations, and the data set WORK.MONEY has 7 observations. How many observations will the data set WORK.EMPSALARY contain?

1. 0

2. 5

3. 7

4. 12

Correct Answer : 1

Exp : Because in it a set statement not merge, so only inemp or insal can be true at a time. answer is '0' observations because the statement 'merge' is not used. At this case, you are either inemp or insal, but not both. In 'SET', only one table is contributing in any one observation of resulting dataset therefore only one 'in=' variable can be true for such observation.

Merging combines observations from two or more SAS data sets into a single observation in a new SAS data set. The new data set contains all variables from all the original data sets unless you specify otherwise.

You merge data sets using the MERGE statement in a DATA step.

Definition of One-to-One Merging

When you use the MERGE statement without a BY statement, SAS combines the first observation in all data sets you name in the MERGE statement into the first observation in the new data set, the second observation in all data sets into the second observation in the new data set, and so on. In a one-to-one merge, the number of observations in the new data set is equal to the number of observations in the largest data set you name in the MERGE statement.

Merging with a BY Statement

Merging with a BY statement enables you to match observations according to the values of the BY variables that you specify. Before you can perform a match-merge, all data sets must be sorted by the variables that you want to use for the merge.

In order to understand match-merging, you must understand three key concepts:

BY variable is a variable named in a BY statement.

BY value is the value of a BY variable.

BY group is the set of all observations with the same value for the BY variable (if there is only one BY variable). If you use more than one variable in a BY statement, then a BY group is the set of observations with a unique combination of values for those variables. In discussions of match-merging, BY groups commonly span more than one data set.

- Details
- Written by Raj Shah

- Details
- Hits: 5935