BookmarkSubscribeRSS Feed

PROC SQL - Update

Started ‎03-25-2024 by
Modified ‎03-25-2024 by
Views 1,173

SQL의 UPDATE문은 테이블의 데이터를 수정할 때 사용합니다.

기본 Syntax는 아래와 같습니다.

 

 

UPDATE 테이블명 
SET 열 = '변경할값'
WHERE 조건;

 

 

image (1).png

 

 

위 데이터는 가상의 데이터로 10명의 이름, 나이, 거주 도시로 구성되어 있습니다.

 

 

 

proc sql;
UPDATE work.import
SET city = 'chef'
WHERE name = '김철';

select * from work.import;

WORK.IMPORT 데이터 중 NAME이 '김철'일 경우, 거주 도시를 'CHEF'로 수정합니다.

 

 

 

image (2).png

 

 

■ Null 값 update

 

image (3).png

 

 

위 데이터는 10명의 가상 데이터로 값이 없는 데이터가 있다.

 

 

proc sql;
update work.import3
set age = 999
where name is null;

select * from work.import3;

 

 

순서는 update > where > set 순이다.

update로 데이터를 수정해야할 테이블을 찾고, where 조건절로 name 변수의 값이 null 인 값을 찾아, age 변수를 999로 수정한다.

 

 

 image (4).png

 

 

 

 

■ Is not Null Update

 

proc sql;
update work.import3
set city = 'newyork'
where city is not null;

select * from work.import3;

 

work.import3 데이터를 NULL 값이 아닌 값을 CITY 변수에 Newyork 로 수정하였다.

 

 

image (5).png

 

 

 

Version history
Last update:
‎03-25-2024 07:01 AM
Updated by:
Contributors

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Article Labels
Article Tags