A00-231 practice question 10 of 10
The variable Name in the data set Employeehas a $CHAR10. format. The variable Name in the data set Sales has a $CHAR15. format. The following SAS program is submitted: data both; length name $ 20; merge sales employee; by id; run; What is the format for the variable Name in the data set Both? Select one:
Full set: 36 questionsIn a SAS DATA step, variable attributes like length and format are determined during the compilation phase before any data is read. The LENGTH statement explicitly sets the storage length of the Name variable to 20 bytes in the output data set Both. However, the question asks for the format, not the length. Since no FORMAT or ATTRIB statement is used to explicitly define a format for Name, SAS inherits the format from the input data sets. When using the MERGE statement, the attributes of common variables are taken from the first data set listed that contains the variable. In this case, sales is the first data set, and the format of Name in sales is $CHAR15.. Therefore, this format is applied to the Name variable in the output data set Both.
A. $20: This is a standard character format, but its width corresponds to the length set by the LENGTH statement. The LENGTH statement does not define the format.
B. $CHAR10: This is the format from the employee data set. Its attributes are ignored because sales is the first data set listed in the MERGE statement.
D. $CHAR20: This format's width matches the length, but it is not automatically assigned. An explicit FORMAT name $CHAR20.; statement would be required to assign this format.
1. SAS 9.4 Statements: Reference, Fourth Edition.
MERGE Statement: In the "Details" section under "Processing Common Variables," the documentation states: "If a variable is common to more than one data set, the variable's attributes in the new data set are the same as its attributes in the first data set that is listed in the MERGE statement that contains the variable." This confirms that attributes are inherited from the sales data set.
LENGTH Statement: The documentation for the LENGTH statement specifies that it sets the number of bytes for storing variables. It does not state that it also sets the default format. This distinguishes the function of the LENGTH statement from the FORMAT statement.
2. Delwiche, L. D., & Slaughter, S. J. (2012). The Little SAS Book: A Primer, Fifth Edition. SAS Institute.
Chapter 4, "Combining SAS Data Sets": In the section on merging, the authors explain the rule for conflicting variable attributes: "If a variable has different attributes (type, length, format, informat, or label) in the data sets you are merging, then SAS uses the attributes from the first data set listed in the MERGE statement that contains the variable." (p. 118). This directly supports the answer.
3. University of California, Los Angeles (UCLA), Institute for Digital Research and Education (IDRE).
SAS Library - Combining Datasets: In the article discussing MERGE, it clarifies the attribute inheritance rule: "When merging datasets, if a variable is in more than one of the datasets, the new dataset will have the attributes (e.g. length, format) of that variable from the first dataset listed on the merge statement." This academic resource corroborates the official documentation.
Keep practicing
Take the free A00-231 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
