BookmarkSubscribeRSS Feed
cmemtsa
Quartz | Level 8

 

Trying to set Column A on Table CONT with value of 1 based on criteria of Column CU on Table CONT and Column Flag on Table CUST.

 

 

proc sql;

UPDATE CONT

SET A = 1

WHERE CONT.DATE = CUST.DATE AND CONT.C = CUST.C

AND CUST.FLAG = 'A' AND CONT.CU=1;

QUIT;

3 REPLIES 3
LinusH
Tourmaline | Level 20

You cannot just refer to different tables in the WHERE caluse, you need to speficy a join somehow.

There are laods of examples on how to this on the internet (this is not a SAS specific task, it's plain SQL).

Data never sleeps
PGStats
Opal | Level 21

You might want to try

 

proc sql;
UPDATE CONT
SET A = 1
WHERE cu = 1 and 
exists (select * from CUST where date = CONT.DATE AND c = CONT.C and FLAG = 'A');
QUIT;
PG
cmemtsa
Quartz | Level 8

It worked!!

 

Thanks a lot!

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

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 2174 views
  • 0 likes
  • 3 in conversation