BookmarkSubscribeRSS Feed
forumsguy
Fluorite | Level 6

Hi there,

My task is to list out all files in my current directory which has about 3 sub directories . As we have EG , all pipe commands are disabled but I am able to list out all file names in a dataset by using following code but however I am unable to tweak it for all sub folders as these 3 subdirectories also have  4 folders each. Basically its Q1, Q2 and Q3 and then Q1 consists of folders of January, February and so on .... Need help in modifying this code to take care of all folders....or else if any alternative is there without pipes..plz let me know


filename _folder_ "%bquote(\\jafiles01\SAS Folder\)";
data filenames(keep=memname);
  handle=dopen( '_folder
_' );

  if handle > 0 then do;
    count=dnum(handle);
    do i=1 to count;
      memname=dread(handle,i);
      output filenames;
    end;
  end;
  rc=dclose(handle);
run;
filename _folder_ clear;


7 REPLIES 7
SASKiwi
PROC Star

You might want to check this out as well:

http://support.sas.com/kb/25/074.html

forumsguy
Fluorite | Level 6

Thanks SASKiwi for the link but it still does the same thing. It reads out files from same folder and not the subfolders....

FriedEgg
SAS Employee

What OS are you using?

forumsguy
Fluorite | Level 6

I am using Windows with SAS Enterprise Guide 4.3

FriedEgg
SAS Employee

Is the server you are connecting to through EG also Windows?

polingjw
Quartz | Level 8

Take a look at Jason Secosky's excellent paper "User-Written DATA Step Functions."  Specifically, look at the "directory traversal example."  I would include a link but copy/paste doesn't work for me in this forum. 

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
  • 7 replies
  • 12091 views
  • 2 likes
  • 5 in conversation