The contents of the raw data file AMOUNT are listed below:
--------10-------20-------30
$1,234
$1,234
The following SAS program is submitted:
data test;
infile 'amount';
input @1 salary 6.;
run;
Which one of the following is the value of the SALARY variable?
infile 'amount';
input @1 salary 6.;
run;
Which one of the following is the value of the SALARY variable?
A. 1234
B. 1,234
C. $1,234
D. . (missing numeric value)
B. 1,234
C. $1,234
D. . (missing numeric value)
5 comments:
Answer D:
Wrong informat assigned to salary…so missing value is assigned…the informat that should be used here is comma6.
answer d: the format should be dollar6. because the dollar format both adds a dollar sign and inserts commas where possible
Concur with both. Both of the informats listed, dollar6. and comma6., will actually work to input this data in this case. SAS help lists DOLLARw.d as an alias of COMMAw.d. I think they kept both informats because this makes it easier to use the formats COMMAw.d and DOLLARw.d, which affect how the data is displayed. Here DOLLARw.d formatting will add a $ to the front, while COMMAw.d will not. Here is the SAS help definition of what the COMMAw.d informat does.
---------------------------------
The COMMAw.d informat reads numeric values and removes embedded commas, blanks, dollar signs, percent signs, hyphens, and close parentheses from the input data. The COMMAw.d informat converts an open parenthesis at the beginning of a field to a minus sign.
Answer: D
Existing code produces 'NOTE: Invalid data for salary' in sas log so, missing numeric value in output.
Informat comma6. will give 1234
Informat Comma6. and format comma6. will give 1,234
and Informat comma6. and format dollar6. will give $1,234
Post a Comment