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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1072 views
  • 0 likes
  • 4 in conversation