A raw data record is listed below:
--------10-------20-------30
Printing 750
The following SAS program is submitted:
data bonus;
infile 'file-specification';
input dept $ 1 - 11 number 13 - 15;
run;
infile 'file-specification';
input dept $ 1 - 11 number 13 - 15;
run;
Which one of the following SAS statements completes the program and results in a value of 'Printing750' for the DEPARTMENT
variable?
A. department = trim(dept) number;
B. department = dept input(number,3.);
C. department = trim(dept) || put(number,3.);
D. department = input(dept,11.) || input(number,3.);
3 comments:
Answer C
You would need trim to remove trailing blanks for dept and put() for converting numeric 750 to character
C
C
You may do it without the put, you will have no syntax error. However, if you concatenate a numeric value, that values is converted to a best 12 format, resulting in heading spaces. So result will then be "printing 123". Only if you use a put, it will result in printing123
data flowers1;
input dept $ 1-11 number 13-15;
department = trim(dept) || number;
cards;
Printing 123
;
run;
Post a Comment