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
.
.
.
.
.
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
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 @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.
"Read" is quite vague.
Explain how you need to process these tables and then we can guide you.
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.
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
Thanks, i am going to try it.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.