BookmarkSubscribeRSS Feed
Sandhya
Fluorite | Level 6
Hi,

In my project, I'm supposed to convert the a raw data into a sas value.

the raw data looks like this. It's in the .csv format.

pid
aa101
aa102
aa103
aa104

I want to write a query to pick all the variables from the table where the pid is equal to the list. Like

proc sql;

create table all as select * from abc where pid in ('aa101', 'aa102', 'aa103', 'aa104');

run;

What is the optimal way of doing this?

Thanks in advance.
Sandhya.
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
From your "list", create a SAS file using a DATA step with INFILE / INPUT and then use PROC SQL with a SELECT / JOIN.

Scott Barry
SBBWorks, Inc.

Recommended Google advanced search arguments, this topic/post:

proc sql select match list values site:sas.com

data step programming input data values infile input site:sas.com
Doc_Duke
Rhodochrosite | Level 12
After you create the PID dataset (with one column, called "pid") that Scott recommends, the sort of SQL that you would need using the CREATE statement might look like

create table all as select * from abc where pid in (SELECT pid from PID');

It's called a subquery and you will find out a lot about it with the Google query that Scott provided.

Doc Muhlbaier
Duke
deleted_user
Not applicable
one way to do is to use filter in the data step.

if pid in ('aa101', 'aa102', 'aa103', 'aa104');
Sandhya
Fluorite | Level 6
Thank you. The suggestions really helped. I used proc sql and used a sub-query.

Thanks once again.
Sandy.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1205 views
  • 0 likes
  • 4 in conversation