Hello everyone,
I want to create a sub-folder under WORK folder(temp folder),how to write SAS code to do this?
Thanks!
You can use the "new" DLCREATEDIR option and the PATHNAME function. If you want a FILEREF use PATHNAME again in a FILENAME statement.
Creating a subfolder requires using an operating system command. So the method will vary from operating system to operating system. SAS has methods that allow you to issue an operating system command, so this will be possible. The key question boils down to this:
Suppose you knew the folder that holds the WORK library. (SAS can retrieve that path.) We'll call that "WORK library folder". What operating system command would you issue to create the proper subfolder?
dcreate() function
%let newdir=my_new_subdir;
data _null_;
length command x $ 300;
x = pathname('work');
command = 'mkdir '!!trim(x)!!"/&newdir";
call system(command);
run;
You can use the "new" DLCREATEDIR option and the PATHNAME function. If you want a FILEREF use PATHNAME again in a FILENAME statement.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.