order_id customer shipped
-------- ------------ ---------
9341 Josh Martin 02FEB2009
9874 Rachel Lords 14MAR2009
10233 Takashi Sato 07JUL2009
The variable order_id is numeric; customer is character; and shipped is numeric, contains a SAS date value,and is shown with the DATE9. format.
A programmer would like to create a new variable, ship_note,that shows a character value with the order_id,shipped date, and customer name.
For example, given the first observation ship_note would have the value "Order 9341 shipped on 02FEB2009 to Josh Martin".
Which of the following statement will correctly create the value and assign it to ship_note?
A. ship_note=catx(' ','Order',order_id,'shipped on',input(shipped,date9.),'to',customer);
B. ship_note=catx(' ','Order',order_id,'shipped on',char(shipped,date9.),'to',customer);
C. ship_note=catx(' ','Order',order_id,'shipped on',transwrd(shipped,date9.),'to',customer);
D. ship_note=catx(' ','Order',order_id,'shipped on',put(shipped,date9.),'to',customer);
Answer: D.
本文属于博客:http://www.crackman.net/ 版权归作者所有,欢迎转载!如有转载,请务必注明出处!未经本文作者同意不得用于商业应用。
这里主要考察四个函数的问题,最容易混淆的是INPUT和PUT两个函数。
看看下面的英文解释。
INPUT:To perform character-to-numeric conversion. Also useful in converting
character values such as dates into true SAS numeric date values.
Syntax: INPUT(value, informat) value is a character variable or character expression. informat is a SAS or user-defined informat.
PUT:To perform numeric-to-character conversion or to create a character variable
from a user-defined format. The result of a PUT function is always a
character value.
Syntax: PUT(value, format) value is a character or numeric SAS variable or expression. format is a SAS or user-defined format.