|
Macros for SAS Application Developers
https://github.com/sasjs/core |
Returns a unique hash for each file in a directory. More...
Go to the source code of this file.
Hashes each file in each directory, and then hashes the hashes to create a hash for each directory also.
This makes use of the new hashing_file() and hashing functions, available since 9.4m6. Interestingly, those functions can be used in pure macro, eg:
%put %sysfunc(hashing_file(md5,/path/to/file.blob,0));
Actual usage:
%let fpath=/some/directory; %mp_hashdirectory(&fpath,outds=myhash,maxdepth=2) data _null_; set work.myhash; put (_all_)(=); run;
Whilst files are hashed in their entirety, the logic for creating a folder hash is as follows:
| [in] | inloc | Full filepath of the file to be hashed (unquoted) |
| [in] | iftrue= | (1=1) A condition under which the macro should be executed |
| [in] | maxdepth= | (0) Set to a positive integer to indicate the level of subdirectory scan recursion - eg 3, to go ./3/levels/deep. For unlimited recursion, set to MAX. |
| [in] | method= | (MD5) the hashing method to use. Available options:
|
| [out] | outds= | (work.mp_hashdirectory) The output dataset. Contains:
|
Definition in file mp_hashdirectory.sas.