BookmarkSubscribeRSS Feed

SAS Macro - %BQUOTE

Started a week ago by
Modified a week ago by
Views 93

매크로 변수 안에 특수문자 (&, %, 공백, 괄호 등)가 들어 있을 경우 매크로 코드를 그대로 실행할 경우 warning 싸인이 나타날 수 있습니다.

이 때, %BQUOTE는 특수문자를 매크로 연산자로 인식하지 않고 일반 텍스트로 처리하도록 만들어줍니다.

특수기호는 다음과 같습니다.

  • 산술연산: + - * /

  • 비교연산자: = ^= > <

  • 논리연산자: AND, OR, NOT

  • ;

  • & (매크로 참조)

  • %: 매크로 호출

 

 

■ 예시1)

 

%let jerry = text1;
%let jerry2 = text2 &text1;

%put &jerry2;

 

jerry 변수에 text1 을 저장합니다.

jerry2 변수에 text2 &text1 이라는 값을 지정하고 싶지만, 매크로 변수 jerry 라는 값과 혼돈하여 아래와 같이 warning 싸인이 나타납니다.

 

 

image.png

 

 

 

 

■ 예시2)

 

 

%let jerry = text1;
%let jerry2 = %bquote(text2 & jerry);

%put &jerry2;

 

 

위 예시1과 다르게 %bquote 함수를 사용해 특수문자(or 트리거 문자 ; &) 등을 문자 자체로 취급하도록 마스킹 하는 역할을 합니다.

그래서 jerry2의 값을 보면 text2 & jerry 로 값을 출력하게 됩니다.

 

 

 

image.png

 

 

■ 예시3)

 

%let text = %bquote(a, b, c);
%put &=text;

 

text 변수에 콤마(,) 가 포함되어 있는데 콤바는 매크로에서 구분자로 사용하는 문자입니다.

하지만, %bquote 를 사용하게 되면 문자열 "a, b, c" 그대로 매크로 변수에 저장하게 됩니다.

 

 

image.png

 

Contributors
Version history
Last update:
a week ago
Updated by:

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Article Labels
Article Tags