Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. lib dir '.../folder';
  2. #iterate through all files of dir and extract first five letters of file name;
  3. #open files and do some processesing, aka data steps proc steps;
  4.  
  5. %macro get_filenames(location);
  6. filename _dir_ "%bquote(&location.)";
  7. data filenames(keep=fname);
  8. handle=dopen( '_dir_' );
  9. if handle > 0 then do;
  10. count=dnum(handle);
  11. do i=1 to count;
  12. fname=subpad(dread(handle,i),1,5);/* extract first five letters */
  13. output filenames;
  14. end;
  15. end;
  16. rc=dclose(handle);
  17. run;
  18. filename _dir_ clear;
  19. %mend;
  20.  
  21. %get_filenames("c:temp");
  22.  
  23. proc sql;
  24. create table datasets as
  25. select substr(memname,1,5) as dataset
  26. from dictionary.tables
  27. where libname='LIB'; /* must be uppercase */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement