| Functions and CALL Routines |
| Category: | Character |
| Syntax | |
| Arguments | |
| Details | |
| Comparisons | |
| Examples | |
| See Also |
Syntax |
| CHAR(string, position) |
specifies a character constant, variable, or expression.
is an integer that specifies the position of the character to be returned.
| Details |
In a DATA step, the default length of the target variable for the CHAR function is 1.
If position has a missing value, then CHAR returns a string with a length of 0. Otherwise, CHAR returns a string with a length of 1.
If position is less than or equal to 0, or greater than the length of the string, then CHAR returns a blank. Otherwise, CHAR returns the character at the specified position in the string.
| Comparisons |
The CHAR function returns the same result as SUBPAD(string, position, 1). While the results are the same, the default length of the target variable is different.
| Examples |
The following example shows the results of using the CHAR function.
options pageno=1 ps=64 ls=80 nodate; data test; retain string "abc"; do position = -1 to 4; result=char(string, position); output; end; run; proc print noobs data=test; run;
The SAS System 1
string position result
abc -1
abc 0
abc 1 a
abc 2 b
abc 3 c
abc 4
| See Also |
|
Functions: |
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.