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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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

PG

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21

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

PG
stat_sas
Ammonite | Level 13

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;

twildone
Pyrite | Level 9

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.

PGStats
Opal | Level 21

Seems quite different. Please post as a new question, with a small example. - PG

PG

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 788 views
  • 3 likes
  • 3 in conversation