全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1849 2
2013-05-24

A Brief Discussion of SAS Functions and Call Routines

If you have written any SAS program, you probably used several functions and have an intuitive idea of what functions do. SAS functions perform a computation or manipulation of a value and return a single value. For example, the MONTH function computes the month of the year from a SAS date; the ROUND function can round numeric values; the TODAY function returns the current date.


SAS functions take the form of a function name, followed by a set of parentheses. In these parentheses are usually one or more arguments. (Certain functions such as TODAY take no arguments, but you need to follow the function name with an opening parenthesis and a closing parenthesis anyway to tell SAS that you are referring to the TODAY function, not to a variable called TODAY.) These arguments provide information that the function needs to return a result. For example, the statement DAY_OF_WEEK = WEEKDAY (DATE); computes the day of the week from a SAS date and assigns it to the variable DAY_OF_WEEK. This function, as with all other SAS functions, returns a single value that is either assigned to a variable or used in a SAS expression.

Finally, the arguments to most SAS functions can be variable names, constants (if a character argument is needed, the constant must be in single or double quotation marks), or expressions (that may also contain other functions).


CALL routines have some similarity to SAS functions because they often perform similar operations. However, there are some important differences. CALL routines are not used in assignment statements. Instead, they stand alone as SAS statements. Multiple arguments in a CALL routine can be assigned new values by the routine. For example, the statement CALL SCAN (string, n, position, length); returns the position and the length of the nth "word" in the string. The SCAN function, on the other hand, returns only a single value—the nth word in the string. Indeed, the main reason for using a CALL routine instead of a function is to obtain more than one value in a single statement.




补充内容 (2013-11-3 17:16):
原文转自:http://my.safaribooksonline.com/ ... brief_discussion_of
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2013-5-24 13:01:37
good post!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-5-24 13:10:50
学习了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群