Hi.....I have two variables - Client & Code. I would like to extract a list of Clients with their code where the code is either a 1 or 2 or 3 as well as the other codes for only these same clients. Can this done using a Proc SQL?...Thanks in Advance.
Yes, use an EXISTS clause:
proc sql;
create table want as
select *
from myTable as A
where exists (select * from myTable where client=A.client and code in (1, 2, 3));
quit;
(untested)
PG
Yes, use an EXISTS clause:
proc sql;
create table want as
select *
from myTable as A
where exists (select * from myTable where client=A.client and code in (1, 2, 3));
quit;
(untested)
PG
data have;
input client code;
datalines;
1 1
1 2
2 1
2 2
2 3
3 1
3 2
3 4
3 5
4 8
4 1
;
data list;
input client;
datalines;
1
2
;
proc sql;
select * from have
where client in (select client from list);
quit;
Thanks PG.....if I had 5 variables - Client, date_processed, code, eff_date, and ex_date and wanted to select the row for the Client if the eff_dates and ex_dates are the same for the same client based on the maximum of date_processed to eliminate duplicates. Would a similar proc sql achieve this? Thanks in Advance.
Seems quite different. Please post as a new question, with a small example. - PG
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.