%macro createdirectory( directory= ) ;
data _null_ ;
length directory
path
folder
newdir $128 ;
directory = "&directory" ;
if substr( directory, lengthn( directory ), 1 ) ne "\" then
directory = cats( directory, "\" ) ;
if substr( directory, 1, 2 ) = "\\" then do ;
path = substr( directory, 1, find( directory, "\", 3 ) ) ;
i = 2 ;
end ;
else do ;
i = 1 ;
path = '' ;
end ;
path = cats( path, scan( directory, i, "\" ), "\" ) ;
if fileexist( path ) then do ;
i + 1 ;
do while ( lengthn( scan( directory, i, "\" ) ) ) ;
folder = scan( directory, i, "\" ) ;
newdir = cats( path, folder ) ;
if not fileexist( newdir ) then newdir = dcreate( folder, path ) ;
path = cats( path, folder, "\" ) ;
i + 1 ;
end ;
end ;
run ;
%mend ;
/* EOF: createdirectory.sas */