DATA Step, Macro, Functions and more

Extracting only file names from the folders

Reply
Contributor
Posts: 40

Extracting only file names from the folders

Hi,

 

I have a folder in my local d drive. in that folder i have various Excel, Csv workbooks and Tab files with different names.

 

So here i wanted to just extract the name's and type of the file and size of the file into a data set.

 

Thanks

Valued Guide
Posts: 626

Re: Extracting only file names from the folders

Posted in reply to srinath3111

Look at the f-function: finfo, fopen and the dopen-function together with dread and dnum to iterate over the contents of the directory. If you can execute shell commands, use dir or ls (depending on the os) together with filename statement. There are many examples out there, i am sure you will useful ideas.

Super User
Posts: 10,530

Re: Extracting only file names from the folders

Posted in reply to srinath3111

If your SAS session runs on a remote server, you most probably won't have access to your local drives from SAS code.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 40

Re: Extracting only file names from the folders

Posted in reply to KurtBremser

Hi,

 

When I provide server path's also it wont work?.

 

Thanks.

Super User
Posts: 10,530

Re: Extracting only file names from the folders

Posted in reply to srinath3111

If the resources as seen on your desktop (eg your D:\ drive) are not somehow mounted on the server, then your SAS process can't "see" them.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 40

Re: Extracting only file names from the folders

Posted in reply to KurtBremser

Hi,

 

I am working out in server along with the server path's.

 

Thanks.

Super User
Posts: 10,530

Re: Extracting only file names from the folders

Posted in reply to srinath3111

Please make up your mind. Quote from your original post:

 

"I have a folder in my local d drive."

(emphasis by me)

 

Are we talking about server resources, or resources on your desktop?

 

Please specify in-depth information about your SAS setup, and which data on which location you want to inspect for filenames.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 6 replies
  • 127 views
  • 0 likes
  • 3 in conversation