第一个问题:我选A,模考给的答案是C。给name设置长度的语句是最先出现的,为什么选C呢?
The variable Name in the data set Employee has 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?
A) $20
B) $CHAR10
C) $CHAR15
D) $CHAR20
第二个问题
Suppose you need to create the variable FullName by concatenating the values of
FirstName, which contains first names, and LastName, which contains last names.
What is the best way to remove extra blanks between first names and last names?
a. data work.maillist;
set cert.maillist;
length FullName $ 40;
fullname=trim firstname||' '||lastname;
run;
b. data work.maillist;
set cert.maillist;
length FullName $ 40;
fullname=trim(firstname)||' '||lastname;
run;
c. data work.maillist;
set cert.maillist;
length FullName $ 40;
fullname=trim(firstname)||' '||trim(lastname);
run;
d. data work.maillist;
set cert.maillist;
length FullName $ 40;
fullname=trim(firstname||' '||lastname);
我选C,答案是B。求问各位大佬答案给的解释里的最后一句话该如何理解? 先谢谢啦!
The TRIM function removes trailing blanks from character values. In this case, extra
blanks must be removed from the values of FirstName. Although answer c also
works, the extra TRIM function for the variable LastName is unnecessary. Because
of the LENGTH statement, all values of FullName are padded to 40 characters.