Sample 24738: Search a string for a specified byte using SAS 9.0 functions
Demonstrate some of the ANY functions introduced in SAS 9.0.
These functions can be used to replace logic involving the INDEX
function.
Note:
ANYALPHA - searches a character string for an alphabetic character
ANYDIGIT - searches a character string for a digit
ANYPUNCT - searches a character string for any punctuation
ANYSPACE - searches a character string for any white space
For a complete list of these functions, please see SAS Note 35758
which contains a link to the SAS Online Documentations section Functions by Category. That same note also contains a link to SAS Note 15435 which has sample code to see what characters would be found by some of the new functions.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/* Note the last byte in 'HELL0' is a zero */
data test;
input test $5.;
Alphas='N';
Digits='N';
Punctuation='N';
Space='N';
if anyalpha(test) >0 then Alphas='Y';
if anydigit(test) >0 then Digits='Y';
if anypunct(test) >0 then Punctuation='Y';
if trim(anyspace(test)) >0 then Space='Y';
datalines;
12.34
abcd
HELL0
4,231
;
proc print;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Obs test Alphas Digits Punctuation Space
1 12.34 N Y Y N
2 abcd Y N N Y
3 HELL0 Y Y N N
4 4,231 N Y Y N
Demonstrate some of the ANY functions introduced in SAS 9.0.
These functions can be used to replace logic involving the INDEX
function.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Functions ==> Character
|
| Date Modified: | 2009-05-07 10:03:54 |
| Date Created: | 2004-09-30 14:09:09 |
Operating System and Release Information
| SAS System | Base SAS | Tru64 UNIX | 9 TS M0 | n/a |
| OpenVMS Alpha | 9 TS M0 | n/a |
| HP-UX IPF | 9 TS M0 | n/a |
| Linux | 9 TS M0 | n/a |
| 64-bit Enabled Solaris | 9 TS M0 | n/a |
| 64-bit Enabled HP-UX | 9 TS M0 | n/a |
| 64-bit Enabled AIX | 9 TS M0 | n/a |
| Microsoft® Windows® for 64-Bit Itanium-based Systems | 9 TS M0 | n/a |
| z/OS | 9 TS M0 | n/a |