Help using Base SAS procedures

converting a sas dataset into a variable value

Reply
Contributor
Posts: 57

converting a sas dataset into a variable value

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.
Super Contributor
Super Contributor
Posts: 3,174

Re: converting a sas dataset into a variable value

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
Trusted Advisor
Posts: 2,113

Re: converting a sas dataset into a variable value

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
N/A
Posts: 0

Re: converting a sas dataset into a variable value

one way to do is to use filter in the data step.

if pid in ('aa101', 'aa102', 'aa103', 'aa104');
Contributor
Posts: 57

Re: converting a sas dataset into a variable value

Thank you. The suggestions really helped. I used proc sql and used a sub-query.

Thanks once again.
Sandy.
Ask a Question
Discussion stats
  • 4 replies
  • 248 views
  • 0 likes
  • 4 in conversation