This generates a dataset containing all the files and directories in the selected Linux path.
Fields derived include
dir, file_mode, number_of_links, owner_name, group_name, bytes, date_last_modified, time_modified, file_name.
As always, YMMV.
%let directory=//mnt/nfs/; filename tmp pipe "ls -mlR --full-time -1 &directory"; data want12; infile tmp dlm="¬"; length dir_line $2000; input dir_line; run; proc sql noprint; select max(countw(dir_line, ' ')) into :maxwords trimmed from want12; quit; data want; set want12; format dir $200.; retain dir; words = countw(dir_line, ' '); if find(dir_line,"/") then dir=dir_line; array parsed_vars(*) $200 new_var1-new_var&maxwords; i=1; do while(i<words or scan(dir_line, i, " ") ne "" or i=1); if find(dir_line,"/")=0 and scan(dir_line, i, " ") ne "" and i<>1 then parsed_vars(i) =scan(dir_line, i, " "); else if i=1 then parsed_vars(i)=dir_line; i+1; end; if not find(dir_line,"/") and words>5 then do; file_mode=new_var1; number_of_links=new_var2; owner_name=new_var3; group_name=new_var4; bytes=input(new_var5,comma12.); date_last_modified=new_var6; time_modified=new_var7; if length(scan(dir_line, 8, " "))>0 and substr(dir_line,1,1)='-' then file_name=substr(dir_line, find(dir_line,scan(dir_line, 8, " ")) +length(scan(dir_line, 8, " "))+1, length(dir_line)-find(dir_line,scan(dir_line, 8, " "))); end; run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.