69%macro mp_hashdirectory(inloc,
70 outds=work.mp_hashdirectory,
76%local curlevel tempds maxlevel;
78%
if not(%eval(%unquote(&iftrue))) %then %
return;
81%mp_dirlist(path=&inloc, outds=&outds, maxdepth=&maxdepth, showparent=YES)
85 set &outds (rename=(filepath=file_path));
86 length FILE_HASH $32 HASH_DURATION 8;
87 keep directory file_hash hash_duration file_path file_or_folder level;
90 if file_or_folder=
'file' then
do;
93 drop fname val fid is_empty;
94 rc=filename(fname,file_path);
98 is_empty=fget(fid,val);
102 if is_empty ne 0 then delete;
103 else file_hash=hashing_file(
"&method",cats(file_path),0);
105 hash_duration=datetime()-ts;
108proc sort data=&outds ;
109 by descending level directory file_path;
115 call symputx(
'maxlevel',level,
'l');
120%
do curlevel=&maxlevel %to 0 %by -1;
121 data work._data_ (keep=directory file_hash);
123 where level=&curlevel;
124 by descending level directory file_path;
125 length str $32767 tmp_hash $32;
126 retain str tmp_hash ;
128 if first.directory then
do;
135 str=cats(str,file_hash);
136 if mod(i,100)=0 or last.directory then
do;
137 tmp_hash=hashing(
"&method",cats(tmp_hash,str));
141 if last.directory then
do;
145 if last.level then stop;
147 %let tempds=&syslast;
149 proc sql undo_policy=none;
150 create table &outds as
152 ,coalesce(b.file_hash,a.file_hash) as file_hash
159 on a.file_path=b.directory
160 order by level desc, directory, file_path;
164%mend mp_hashdirectory;