Home > Preliminary Draft ***** Subject to Change ***** Totally Unofficial

Preliminary Draft ***** Subject to Change ***** Totally Unofficial

Preliminary Draft ***** Subject to Change ***** Totally Unofficial

COMPRESS function, version 9.1 and later Jun 4, 2002

Note: the third argument is new in 9.1

Returns the first argument with characters removed as specified
by the second and third arguments

Category: Character

Syntax:
COMPRESS( <source> <, <chars> <, <modifiers>>>)

source
is a character string from which characters are removed.

chars
is a character string initializing a list of characters. By
default, the characters in this list are removed from the result.
If you specify the "K" modifier in the third argument, only the
characters in this list are kept in the result. You can add more
characters to this list using other modifiers in the third
argument.

modifiers
is a character string in which each nonblank character modifies
the action of the COMPRESS function. Blanks are ignored.
The characters that may be used as modifiers are:

a or A adds alphabetic characters to the list of characters.

c or C adds control characters to the list of characters.

d or D adds digits to the list of characters.

f or F adds an underscore and English letters (that is, the
characters that can begin a SAS variable name using
VALIDVARNAME=V7) to the list of characters.

g or G adds graphic characters to the list of characters.

i or I ignores the case of the characters to be kept or removed.

k or K keeps characters from the list instead of removing them.

l or L adds lower case letters to the list of characters.

n or N adds digits, an underscore, and English letters (that is,
the characters that can appear in a SAS variable name
using VALIDVARNAME=V7) to the list of characters.

o or O processes the second and third arguments only once,
rather than every time the COMPRESS function is called.
Using the "O" modifier in the DATA step (excluding WHERE
clauses) or the SQL procedure can make COMPRESS run much
faster when you call it in a loop where the second and
third arguments do not change.

p or P adds punctuation marks to the list of characters.

s or S adds space characters to the list of characters
(blank, horizontal tab, vertical tab, carriage return,
line feed, and form feed).

t or T trims trailing blanks from the first and second arguments.

u or U adds upper case letters to the list of characters.

w or W adds printable characters to the list of characters
("W" for writable, since "P" is used for punctuation).

x or X adds hex digits to the list of characters.


Details:

The COMPRESS function allows null arguments. A null argument is
treated as a string with a length of zero.

If COMPRESS is called with only one argument, the result is the
argument with all blanks removed. If the argument is completely
blank, the result is a string with a length of zero. If the result
is assigned to a character variable with a fixed length, the value
of that variable will be padded with blanks out to its defined length.

If COMPRESS is called with two arguments, all characters that appear
in the second argument are removed from the result.

If COMPRESS is called with three arguments, the "K" modifier (specified
in the third argument) determines whether the characters in the second
argument are kept in or removed from the result. COMPRESS compiles a
list of characters to keep or remove, comprising the characters in the
second argument plus any types of characters specified via modifiers.
For example, the "D" modifier specifies digits, so both of the following
calls remove digits from the result:

COMPRESS( source, "1234567890")
COMPRESS( source, , "d")

To remove digits and plus or minus signs, you could use either of the
following calls:

COMPRESS( source, "1234567890+-")
COMPRESS( source, "+-", "d")

Recent Documents:

Set Home | Add to Favorites

All Rights Reserved Powered by Free Document Search and Download

Copyright © 2011
This site does not host pdf,doc,ppt,xls,rtf,txt files all document are the property of their respective owners. complaint#nuokui.com
TOP