Posted By

rambles on 05/26/11


Tagged

sas DataManagement


Versions (?)

Output list of files and folders to a dataset


 / Published in: SAS
 

This simple, straightforward method should work on multiple platforms (other methods involving OS specific commands and pipes are less flexible).

  1. filename parent "/lvl1/lvl2";
  2.  
  3. data files_and_folders;
  4. length name $50;
  5. drop rc did i;
  6. did=dopen("parent");
  7. if did > 0 then do;
  8. do i=1 to dnum(did);
  9. name=dread(did,i);
  10. output;
  11. end;
  12. rc=dclose(did);
  13. end;
  14. else put 'Could not open directory';
  15. run;

Report this snippet  

You need to login to post a comment.