BookmarkSubscribeRSS Feed
Idan
Calcite | Level 5
Help! Does anyone know how to create a folder in Windows using SAS without using the X Command (aka on SAS Server - EG)? Can it be done?
1 REPLY 1
tbellmer
Fluorite | Level 6
%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 */

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1755 views
  • 0 likes
  • 2 in conversation