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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 974 views
  • 0 likes
  • 4 in conversation