![]() |
|
SAS Tip
of the Month Sometimes we need to know if a character variable contains a number, character, or both, or punctuation -- granted, the latter is rare, but it is sometimes still needed. There are a few functions that can help us with this. These are:
In all cases it finds the first character that meets the condition. The following code demonstrates its use: 198 data _null_; 199 TextStr='1313 Mockingbird Lane, Mockingbird Heights'; 200 FirstALNUM=ANYALNUM(TextStr); 201 FirstALPHA=ANYALPHA(TextStr); 202 FirstDIGIT=ANYDIGIT(TextStr); 203 FirstPUNCT=ANYPUNCT(TextStr); 204 put TextStr= / 205 FirstALNUM= FirstALPHA= FirstDIGIT= FirstPUNCT=; 206 run; TextStr=1313 Mockingbird Lane, Mockingbird Heights FirstALNUM=1 FirstALPHA=6 FirstDIGIT=1 FirstPUNCT=22 |
|
| ________________________________ Updated August 1, 2006 |
|