Help using Base SAS procedures

create sub folder in work

Accepted Solution Solved
Reply
Regular Contributor
Posts: 241
Accepted Solution

create sub folder in work

Hello everyone,

I want to create a sub-folder under WORK folder(temp folder),how to write SAS code to do this?

Thanks!


Accepted Solutions
Solution
‎04-02-2015 10:03 AM
Respected Advisor
Posts: 3,799

Re: create sub folder in work

Posted in reply to GeorgeSAS

You can use the "new" DLCREATEDIR option and the PATHNAME function.  If you want a FILEREF use PATHNAME again in a FILENAME statement.

options DLCREATEDIR=1;
libname FT51F001 "%sysfunc(pathname(work,L))/subfolderinwork";

View solution in original post


All Replies
Super User
Posts: 5,505

Re: create sub folder in work

Posted in reply to GeorgeSAS

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?


Super User
Posts: 19,805

Re: create sub folder in work

Posted in reply to GeorgeSAS

dcreate() function

Super User
Posts: 7,782

Re: create sub folder in work

Posted in reply to GeorgeSAS

%let newdir=my_new_subdir;

data _null_;

length command x $ 300;

x = pathname('work');

command = 'mkdir '!!trim(x)!!"/&newdir";

call system(command);

run;

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎04-02-2015 10:03 AM
Respected Advisor
Posts: 3,799

Re: create sub folder in work

Posted in reply to GeorgeSAS

You can use the "new" DLCREATEDIR option and the PATHNAME function.  If you want a FILEREF use PATHNAME again in a FILENAME statement.

options DLCREATEDIR=1;
libname FT51F001 "%sysfunc(pathname(work,L))/subfolderinwork";
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 864 views
  • 3 likes
  • 5 in conversation