BookmarkSubscribeRSS Feed

PROC SQL - Update

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

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

 

 

 

Contributors
Version history
Last update:
‎03-25-2024 07:01 AM
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