Chapter Contents |
Previous |
Next |
Restrictions on Function Arguments |
Characteristics of Target Variables |
Function | Target Variable Type | Target Variable Length (bytes) |
---|---|---|
BYTE | character | 1 |
COMPRESS | character | length of first argument |
INPUT | character | width of informat |
numeric | 8 | |
LEFT | character | length of argument |
PUT | character | width of format |
REVERSE | character | length of argument |
RIGHT | character | length of argument |
SUBSTR | character | length of first argument |
TRANSLATE | character | length of first argument |
TRIM | character | length of argument |
UPCASE, LOWCASE | character | length of argument |
VTYPE, VTYPEX | character | 1 |
Notes on Descriptive Statistic Functions |
Notes on Financial Functions |
SAS provides a group of functions that perform financial calculations. The functions are grouped into the following types:
Function type | Functions | Description | |
---|---|---|---|
Cashflow | CONVX, CONVXP | calculates convexity for cashflows | |
DUR, DURP | calculates modified duration for cashflows | ||
PVP, YIELDP | calculates present value and yield-to-maturity for a periodic cashflow | ||
Parameter calculations | COMPOUND | calculates compound interest parameters | |
MORT | calculates amortization parameters | ||
Internal rate of return | INTRR, IRR | calculates the internal rate of return | |
Net present and future value | NETPV, NPV | calculates net present and future values | |
SAVING | calculates the future value of periodic saving | ||
Depreciation | DACCxx | calculates the accumulated depreciation up to the specified period | |
DEPxxx | calculates depreciation for a single period |
Using DATA Step Functions within Macro Functions |
%SYSFUNC arguments are a single DATA step function and an optional format, as shown in the following examples:
%sysfunc(date(),worddate.) %sysfunc(attrn(&dsid,NOBS))
You cannot nest DATA step functions within %SYSFUNC. However, you can nest %SYSFUNC functions that call DATA step functions. For example:
%sysfunc(compress(%sysfunc(getoption(sasautos)), %str(%)%(%')));
All arguments in DATA step functions within %SYSFUNC must be separated by commas. You cannot use argument lists that are preceded by the word OF.
Because %SYSFUNC is a macro function, you do not need to enclose character values in quotation marks as you do in DATA step functions. For example, the arguments to the OPEN function are enclosed in quotation marks when you use the function alone, but the arguments do not require quotation marks when you use them within %SYSFUNC.
dsid=open("sasuser.houses","i"); dsid=open("&mydata","&mode"); %let dsid=%sysfunc(open(sasuser.houses,i)); %let dsid=%sysfunc(open(&mydata,&mode));
You can use these functions to call all of the DATA step SAS functions except those that pertain to DATA step variables or processing. These prohibited functions are: DIF, DIM, HBOUND, INPUT, IORCMSG, LAG, LBOUND, MISSING, PUT, RESOLVE, SYMGET, and all of the variable information functions (for example, VLABEL).
Using Functions to Manipulate Files |
When you use external files, the FOPEN function allocates a buffer called the File Data Buffer (FDB) and opens the external file for reading or updating. The FREAD function reads a record from the external file and copies the data into the FDB. The FGET function then moves the data to the DATA step variables. The function returns a value that you can check with statements or other functions in the DATA step to determine how to further process your data. After the records are processed, the FWRITE function writes the contents of the FDB to the external file, and the FCLOSE function closes the file.
When you use SAS data sets, the OPEN function opens the data set. The FETCH and FETCHOBS functions read observations from an open SAS data set into the Data Set Data Vector (DDV). The GETVARC and GETVARN functions then move the data to DATA step variables. The functions return a value that you can check with statements or other functions in the DATA step to determine how you want to further process your data. After the data is processed, the CLOSE function closes the data set.
For a complete listing of functions and CALL routines, see Categories and Descriptions of Functions. For complete descriptions and examples, see SAS Language Reference: Dictionary.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.