BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Appy18
Calcite | Level 5

Hello all,

I had a query.Folder all_data contains multiple .sas7bdat files. I need to read it . I know how to read sinlge file but cant figure out anything regardig this.

I am new to sas, plz guide me a little.

 

sample data_

all_data

abc.sas7bdat

xzy.sas7bdat

pqr.sas7bdat

stv.sas7bdat

.

.

.

.

.

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

@HannaZhang 

If you just need a single libref which includes SAS tables from multiple folders then there is no need to physically copy these tables into a single folder. Instead define a libname which includes multiple paths. 

You can look-up how that's done by searching using a terms like "SAS Library Concatenation"

 

N.B: If using a concatenated library then SAS traverses the paths in the order in which they are listed in the library definition.

-  in case of the same table name (file name) existing in multiple folders SAS will return the first table found

-  if creating (writing) a new table (or replacing an existing table) then SAS will create this table in the first folder in the concatenated path 

View solution in original post

8 REPLIES 8
Jagadishkatam
Amethyst | Level 16

You can assign a library with the location where the datasets are located and then use a data step to read the datasets.

 

libname source '~path of folder with datasets';

data want;
set source.x1 ;
run;

data want2;
set source.x2;
run;

Thanks,
Jag
Appy18
Calcite | Level 5

thanks @Jagadishkatam, but i think this way i have to define all the files in my folder .(correct me if i am wrong). I  don't want to do that.

LinusH
Tourmaline | Level 20

"Read" is quite vague.

Explain how you need to process these tables and then we can guide you.

Data never sleeps
Appy18
Calcite | Level 5

By 'read' i mean i want to view the files. Because these are the files that i got from a source and i dont know what type of data it consists. so i was looking for something that helps me in viewing the data set this folder holds. and since the folder contains multiple file, i was looking for something like macro. But since i dont have command over macro programming so i am seeking your help.If there is anyother way please suggest me.

Astounding
PROC Star
A report would be a good start. Assuming you know where the data sets are stored:

libname perm 'path to folder holding data';

proc contents data=perm._all_;
run;
HannaZhang
Obsidian | Level 7
I dont think I understand what is your question .Is there 1)a folder with many datasets which you want to read into sas,2)or many folds that each one with many datasets?
if you are in case 1),I think you can use" libname source '~path of folder with datasets;"
if not,my suggestion is that organizing all folders into one folder,then you can use “libname”
Patrick
Opal | Level 21

@HannaZhang 

If you just need a single libref which includes SAS tables from multiple folders then there is no need to physically copy these tables into a single folder. Instead define a libname which includes multiple paths. 

You can look-up how that's done by searching using a terms like "SAS Library Concatenation"

 

N.B: If using a concatenated library then SAS traverses the paths in the order in which they are listed in the library definition.

-  in case of the same table name (file name) existing in multiple folders SAS will return the first table found

-  if creating (writing) a new table (or replacing an existing table) then SAS will create this table in the first folder in the concatenated path 

Appy18
Calcite | Level 5

Thanks, i am going to try it.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 8 replies
  • 1700 views
  • 0 likes
  • 6 in conversation