Hi all,
I am having trouble importing data from a zipped DBF file in SAS 9.3 (using EG 5.1).
As-is situation
Right now, I have to manually unzip the weekly updates and import the DBF files using proc import with DBMS set to 'DBF'.
To-be situation
Read and import the DBF files directly from the zipfiles.
Approach
Declare the zipfile using the filename statement and SASZIPAM option and import the DBF file using a datastep, as described here.
Problem
There are 2 problems, either of which would be a solution if solved:
Any ideas on how to best approach this?
Cheers,
Kirvis
Thanks again for your reply.
I have eventually managed to activate 7-zip using the following code:
data _null_ ;
unzipcmd= ' "C:\Program Files\7-zip\7z.exe" ' ;
zipfile= 'C:\MyDocuments\zipfile.zip' ;
whereto= 'C:\MyDocuments\target_dir\' ;
cmd=unzipcmd || ' x ' || zipfile || ' o-' || whereto ;
putlog "NOTE-Files are extracted" cmd ;
call system(cmd);
run;
I realise I can make this more flexible using macro variables and things like that, but for now, this does work.
Thanks!
can you upgrade to sas 9.4? New features Zip filename.
With 9.3 you could use ODS Document for zipping/unzipping
import usage, why not use proc dbf?
SAS/ACCESS(R) 9.4 Interface to PC Files: Reference, Second Edition (proc dbf)
SAS/ACCESS(R) 9.3 Interface to PC Files: Reference (proc dbf)
Hi Jaap,
Thanks for your reply. To comment on it:
Unzipping the files on the server and importing them would be a third option, but I have not managed to figure that out either.
Thanks
Ok, you will need always a two-step process approach 1/ the unzip 2/ dbf to SAS
I Checked the ODS package approach it will allow you to zip but I cannot find unzip. That is a weird approach at SAS as a lot is related to ZIP-functionality although not always made visible.
The two steps can be done in your case by
-unzip step (possible containing many files) using a XCMD (pipe systask processing) . That should work with SAS 9.3 at SAS/base windows (SASZIPAM is windows only)
- the conversion step.
you can specify needed checkpoints in your process as for existence of the wanted filenames.
Still one program or EGP-flow with several steps you can run.
Thanks again for your reply.
I have eventually managed to activate 7-zip using the following code:
data _null_ ;
unzipcmd= ' "C:\Program Files\7-zip\7z.exe" ' ;
zipfile= 'C:\MyDocuments\zipfile.zip' ;
whereto= 'C:\MyDocuments\target_dir\' ;
cmd=unzipcmd || ' x ' || zipfile || ' o-' || whereto ;
putlog "NOTE-Files are extracted" cmd ;
call system(cmd);
run;
I realise I can make this more flexible using macro variables and things like that, but for now, this does work.
Thanks!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.