Hello everyone, I am new to this forum and pretty much to SAS in general, so if there are any beginner mistakes from my side, I apologise in advance! My task ist to get the File size and the md5 checksum of some ZIP files I created with SAS. To get the file size I used the fopen and finfo functions, which worked very well. In this SAS Blog I read, that you can acess the checksum of a zip file with finfo(fid, 'CR-32'). Sadly it does not work on my files. I get ‚202020202020202020202020‘ as a result, so i assume it is just a blank in the hex32 format. I have to say, I dind´t find this option in the official SAS documentation. Why does this option not work on my Code? Is it because it does not work in general, or because the checksum information is not saved in the ZIP file? If getting the checksum with finfo is not possible, is there another simple alternative to get the checksum from an extern ZIP file with SAS? I created the ZIP files with the ODS Option in SAS, maybe it is simpler to get the checksum during the creation of the ZIP File? Any suggestions about that? Thanks in advance! data XXXX;
* Assign the fileref '_FILES' to the directory location;
FILENAME _FILES "XXXPATH";
FORMAT md5 $hex32.
* Opens up the directory, dir is now the directory id;
dirid=dopen('_FILES');
* Numfiles is equivalent to the number of files in the directory;
numfiles=dnum(dirid);
* Loop around each file;
do i=1 to numfiles;
* Identify the file as fname;
Filename=dread(dirid,i);
* Find the file in the location;
file=" XXXPATH "||Filename;
* Assign the fileref '_FNAMES' to this file;
sysrc=filename('_FNAMES', file);
* Open the file;
fid =fopen('_FNAMES');
* If the files is open;
if fid ^= 0 then do;
* Get all of the file information;
Bytes =finfo(fid ,'File Size (Bytes)');
md5 =finfo(fid ,'md5');
* Output for each file in the directory;
output;
* Close the file;
sysrc=fclose(fid);
end;
end;
* Close the directory;
rc=close(dirid);
run;
... View more