반응형
목적
오늘은 SAS Character 함수 중 COMPRESS 함수에 대해 알아보자.
문법
COMPRESS(source,characters,modifier)
: 문자열에서 특정 문자를 제거
<Modifier>
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 the underscore character and English letters to the list of characters. |
g or G | adds graphic characters to the list of characters. |
h or H | adds a horizontal tab to the list of characters. |
i or I | ignores the case of the characters to be kept or removed. |
k or K | keeps the characters in the list instead of removing them. |
l or L | adds lowercase letters to the list of characters. |
n or N | adds digits, the underscore character, and English letters to the list of characters. |
o or O | processes the second and third arguments once rather than every time the COMPRESS function is called. Using the O modifier in the DATA step (excluding WHERE clauses), or in 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 (blank, horizontal tab, vertical tab, carriage return, line feed, form feed, and NBSP ('A0'x, or 160 decimal ASCII) to the list of characters. |
t or T | trims trailing blanks from the first and second arguments. |
u or U | adds uppercase letters to the list of characters. |
w or W | adds printable characters to the list of characters. |
x or X | adds hexadecimal characters to the list of characters. |
예제
data a; length a $100.; a='AB C D EFG HI J'; b=compress(a); output; a='456-8877-0641 AB 234-5678-9012 cd'; b=compress(a,'ABCD'); output; a='456-8877-0641 AB 234-5678-9012 cd'; b=compress(a,'ABCD','k'); output; run; proc print data=a; run; |
SAS 코드 실행 결과는 아래와 같다.
![]() |
모든 SAS 함수 정보를 보고 싶다면 아래 링크 Click
ALL SAS Functions - SAS - Statistical Analysis System (google.com)
반응형
'끄적이는 프로그래밍 > SAS 함수' 카테고리의 다른 글
[SAS Character Functions] INDEX() (0) | 2022.11.10 |
---|---|
[SAS Character Functions] DEQUOTE() (0) | 2022.11.10 |
[SAS Character Functions] COMPBL() (0) | 2022.11.09 |
[SAS Character Functions] COLLATE() (0) | 2022.11.09 |
[SAS Character Functions] BYTE() (0) | 2022.11.08 |