第54題,下面是題目和crackman的解析,想問下關(guān)于 city 和state的長度是否被截?cái)啵浚?/strong>
謝謝大神們!
54.Consider the following data step:
data WORK.TEST;
setSASHELP.CLASS(obs=5);
retain City'Beverly Hills';
State='California';
run;
The computed variables City and State have their valuesassigned using two different methods, a RETAIN statement and an Assignmentstatement. Which statement regarding this program is true?
A. The RETAINstatement is fine, but the value of City will be truncated to 8
bytes as the LENGTH statement has been omitted.
B. Both theRETAIN and assignment statement are being used to initialize new
variables and are equally efficient. Method used is amatter of programmer preference.
C. The assignmentstatement is fine, but the value of City will be truncated
to 8 bytes as the LENGTH statement has been omitted.
D. City's value will be assigned one time,State's value 5 times.
Answer: D
其實(shí)這里考察的RETAIN到底是在非執(zhí)行語句還是執(zhí)行語句。
RETAIN的作用是初始化變量為“特定的默認(rèn)值”,是非執(zhí)行語句,在編譯過程中,PDV中用“特定的默認(rèn)值”替代SAS系統(tǒng)默認(rèn)值。在DATA步中,加 入STATE進(jìn)入PDV中,STATE=’California’; 是賦值語句,也就是執(zhí)行語句。每一次從SASHELP.CLASS讀取數(shù)據(jù)之后,都要執(zhí)行一次賦值語句。