BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Mohan03
Fluorite | Level 6

Hi,

I have 2 tables (whole_set & mismatches) derived from 2 data steps (abc_vers & xyz_vers), as below:

 

title ' full set ';
create table whole_set as
select source, rec_no, rec_01 from
(
select 'abc', monotonic() as rec_no, rec_01 from abc_vers
union
select 'xyz', monotonic() as rec_no, rec_01 from xyz_vers
)
as tbl01 (source, rec_no, rec_01)
where source = 'abc'
group by rec_01
having count(*) <= 2
order by rec_no
;

 

title ' mismatch set ';
create table mismatches as
select * from
(
select 'rowz2add', rec_01 from fis_vers
except
select 'rowz2add', rec_01 from nab_vers
union
select 'rowz2del', rec_01 from nab_vers
where substr(rec_01,66,1) = 'L'
and substr(rec_01,67,1) in ('0','1','2','3','4','5','6','7','8','9')
and substr(rec_01,68,1) in ('0','1','2','3','4','5','6','7','8','9')
and substr(rec_01,69,1) in ('0','1','2','3','4','5','6','7','8','9')
except
select 'rowz2del', rec_01 from fis_vers
where substr(rec_01,66,1) = 'L'
and substr(rec_01,67,1) in ('0','1','2','3','4','5','6','7','8','9')
and substr(rec_01,68,1) in ('0','1','2','3','4','5','6','7','8','9')
and substr(rec_01,69,1) in ('0','1','2','3','4','5','6','7','8','9')
)
as tbl01
(
action, rec_01
);

 

My requirement - for every record in the "mismatches" table, its equivalent records to be deleted from the "whole_set" table...

 

Used the "Delete" query below and it works when the 'Sub-Query" fetches 1 record but flops when there are multiple records:

delete from whole_set
where rec_01 = (select rec_01 from mismatches where action = 'rowz2del') ;

 

Is there a way to iterate (in PROC SQL) through the rows and delete them from the whole_set (something like - get the count from mismatches table and then a 'DO' loop until all the records are deleted) ?

 

Thanks,

Mohan

1 ACCEPTED SOLUTION
2 REPLIES 2

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

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 5795 views
  • 1 like
  • 2 in conversation