BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
csetzkorn
Lapis Lazuli | Level 10

Let us say I have a massive tab separated file stored in a network drive visible to SAS. The file contains these columns:

 

 

 

Can I access this file via, for axample PROC SQL, to only populate a SAS dataset based on a subset of this data (e.g. where Id = 1234)?

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

If you use a datastep you can filter data while reading the external file, but if possible

better read the whole file then filter as need using sas tools.

View solution in original post

5 REPLIES 5
Shmuel
Garnet | Level 18

SAS sql will handle SAS dataset, not a TAB separated file.

You need first to import it into sas  using FILENAME ... DLM='09'x;

Use either proc import or a datastep to read the file;

csetzkorn
Lapis Lazuli | Level 10
OK thanks. Can I apply filter here?
ballardw
Super User

I would suggest reading the entire set into SAS. Then you can subset with a WHERE clause in Proc SQL to your hearts content.

 

I do not know the number of times I have had someone tell me we need the "XYZ" values only. And then finish the project and get told "need ABC and XYZ_2" also. If you subset the data too early then you may be rereading the data from scratch many times.

Shmuel
Garnet | Level 18

If you use a datastep you can filter data while reading the external file, but if possible

better read the whole file then filter as need using sas tools.

Kurt_Bremser
Super User

A subsetting if can be used in a data step that reads from a flat file. But I would only contemplate this if the dataset grows to considerable size. Otherwise you're better off by subsetting later.

 

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 502 views
  • 0 likes
  • 4 in conversation