1.
The following SAS program is submitted:
data work.retail;
cost = '20000';
total = .10 * cost;
run;
Which one of the following is the value of the variable TOTAL in the output data
set?
A. 2000
B. '2000'
C. . (missing numeric value)
D. ' ' (missing character value)
答案为A,理由是SAS automaticly converted the character value cost to numeric 20000.
但是另一道题:
30.The descriptor and data portions of the Work.Salaries data set are shown below.
Variable Type Len Pos
name Char 8 0
salary Char 8 16
status Char 8 8
name status salary
Liz S 15,600
Herman S 26,700
Marty S 35,000
The following SAS program is submitted:
proc print data=work.salaries;
where salary<20000;
run;
What is displayed in the SAS log after the program is executed?
a. A NOTE indicating that 1 observation is read.
b. A NOTE indicating that 0 observations were read.
c. A WARNING indicating that character values have been converted to numeric values.
d. An ERROR indicating that the WHERE clause operator requires compatible variables.
答案是D。
我想问为什么第2题SAS没有自动将character转为numeric,而第1题这么做了?
谢谢。