BookmarkSubscribeRSS Feed

찾기 & 바꾸기 Sample Code

Started ‎03-23-2021 by
Modified ‎03-23-2021 by
Views 701

엑셀의 찾기 및 바꾸기와 같은 기능을 구현해 보는 sample code 입니다. 

 

(1) HI, GD 등 영문 2글자로 표시된 모든 글자를 Hello, Good 등의 글자로 한번에 바꾸고 싶을때
(2) 0123010123 과 같은 10자리의숫자를 0123.01-0123 의 형식으로 5번째 자리에 점(.)을, 8번째 자리에 하이픈(-)을 특정 셀의 데이터들에 일괄적으로 넣고 싶을때


data test;

input a $10. c $10.;

datalines;

0123010123 HI

0123010123 HI

0123010123 HI

0123010123 HI

0123010123 GD

0123010123 HI

0123010123 GD

0123010123 HI

0123010123 HI

;

 

data result;

set test;

length b varchar(20);

length d varchar(20);

b = substr(a, 1, 4) || "." || substr(a, 5,2) || "-" || substr(a, 6,4);

if c = 'HI' then

d= tranwrd(c, 'HI', 'Hello');

else if c = 'GD' then

d= tranwrd(c, 'GD', 'Good');

run;

 

Contributors
Version history
Last update:
‎03-23-2021 06:29 PM
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 save with the early bird rate—just $795!

Register now

Article Tags