Created
September 25, 2020 18:20
-
-
Save statgeek/3dd1af207cc55fdc0260d0c7a2457848 to your computer and use it in GitHub Desktop.
SAS - export all files in a library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This program exports all files from a library into CSV files. | |
Author: F. Khurshed | |
Date: 2020-09-25 | |
*/ | |
options dlcreatedir; | |
proc options option=dlcreatedir; | |
run; | |
%let lib2export = WORK; | |
%let path2files = /home/demo/; | |
*list of files; | |
data _null_; | |
set sashelp.vtable(where = (libname = "&lib2export") keep = libname memname); | |
*create folder path for files to be stored; | |
folder4file = catt("&path2files.", memname); | |
*use libname to create folders; | |
rc_open = libname('demo1', folder4file) ; | |
rc_close = libname('demo1'); | |
file2export = catt(folder4file, "/", memname, ".csv"); | |
length str $300.; | |
str = catt("proc export data=", | |
"&lib2export.", | |
".", | |
memname, | |
" outfile=", | |
trim(quote(file2export)), | |
" dbms=csv replace;run;"); | |
call execute (str); | |
run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment