In the following SAS program, the input data files are sorted by the NAMES variable: libname temp 'SAS-data-library'; data temp.sales; merge temp.sales work.receipt; by names; run; Which one of the following results occurs when this program is submitted?
-
The program executes successfully and a temporary SAS data set is created
-
The program executes successfully and a permanent SAS data set is created
-
The program fails execution because the same SAS data set is referenced for both read and write operations
-
The program fails execution because the SAS data sets on the MERGE statement are in two different libraries
In SAS, when you merge datasets and write to a dataset with the same name and library as an input dataset, SAS creates a NEW temporary version in the WORK library first. Since temp.sales is being created in the temp library, it becomes a permanent dataset in that library. The program executes successfully.
To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) The program executes successfully and a temporary SAS data set is created - This option is incorrect. The program does create a SAS data set, but it is not temporary.
Option B) The program executes successfully and a permanent SAS data set is created - This option is correct. The program successfully merges the data sets and creates a permanent SAS data set named "sales" in the "temp" SAS data library.
Option C) The program fails execution because the same SAS data set is referenced for both read and write operations - This option is incorrect. The program merges two different data sets, "temp.sales" and "work.receipt", so there is no conflict in referencing the same data set.
Option D) The program fails execution because the SAS data sets on the MERGE statement are in two different libraries - This option is incorrect. The program merges data sets from two different libraries, but this is not an issue for the MERGE statement.
The correct answer is Option B. The program executes successfully and a permanent SAS data set is created because the data sets are merged based on the "names" variable.