Usage Note 33352: There is a new option in SAS® 9.1.3 for the COMPRESS function that provides more flexibility when removing various characters from a string
The new option MODIFIER allows for more flexibility in compressing out various types of data from a character string.
In the Full Code tab are a few samples using some of these modifiers.
Prior to these MODIFIERS being available, the user would have to type in the entire alphabet to remove any alphabetical character. Now you can add a one character MODIFIER, to remove alphabetical characters, or you can use multiple MODIFIERS to remove various types of other data.
You also have the ability to keep values while letting all other values be removed.
NOTE: Place quotes around the MODIFIERS
Below is the link to the documentation.
The COMPRESS Function
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.1 TS1M3 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M3 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M3 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M3 | |
Microsoft Windows XP 64-bit Edition | 9.1 TS1M3 | |
Microsoft® Windows® for x64 | 9.1 TS1M3 | |
Microsoft Windows 2000 Advanced Server | 9.1 TS1M3 | |
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M3 | |
Microsoft Windows 2000 Server | 9.1 TS1M3 | |
Microsoft Windows 2000 Professional | 9.1 TS1M3 | |
Microsoft Windows NT Workstation | 9.1 TS1M3 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M3 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M3 | |
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M3 | |
Microsoft Windows XP Professional | 9.1 TS1M3 | |
Windows Vista | 9.1 TS1M3 | |
64-bit Enabled AIX | 9.1 TS1M3 | |
64-bit Enabled HP-UX | 9.1 TS1M3 | |
64-bit Enabled Solaris | 9.1 TS1M3 | |
HP-UX IPF | 9.1 TS1M3 | |
Linux | 9.1 TS1M3 | |
OpenVMS Alpha | 9.1 TS1M3 | |
Tru64 UNIX | 9.1 TS1M3 | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
options formdlim=' ';
/* remove special characters and alpha */
/* characters and just keep the numerics */
data one;
x='1a2mc45kch!6@8#9$%^&';
n=compress(x, , 'kd');
proc print;
run;
/* remove all alpha characters */
data two;
x='abc12def984';
n=compress(x, , 'a');
run;
proc print;
run;
/* remove blanks and punctuation */
data three;
x='string, with punctuation! Really?';
n=compress(x, ' ', 'p');
run;
proc print;
run;
options formdlim='';
The SAS System 14:57 Wednesday, September 17, 2008 41
Obs x n
1 1a2mc45kch!6@8#9$%^& 1245689
The SAS System 14:57 Wednesday, September 17, 2008 42
Obs x n
1 abc12def984 12984
The SAS System 14:57 Wednesday, September 17, 2008 43
Obs x n
1 string, with punctuation! Really? stringwithpunctuationReally
Type: | Usage Note |
Priority: | |
Topic: | SAS Reference ==> Functions ==> Character ==> COMPRESS
|
Date Modified: | 2010-08-02 15:27:18 |
Date Created: | 2008-09-18 16:14:26 |