How to create folder at UNIX in SAS program?

Accepted Solution Solved
Reply
Regular Contributor
Posts: 230
Accepted Solution

How to create folder at UNIX in SAS program?

Hello All,

 

After I run a SAS program in UNIX the program can create a folder " /home/A123456ABC/XYZ/ABC"  for me. how to write the SAS code?

 

Thanks!

 

x123456789-aaa-15$ pwd
/home/A123456ABC/My_report
x123456789-aaa-16$  sas the_code_needed.sas


Accepted Solutions
Solution
‎04-28-2017 02:01 PM
Super User
Posts: 5,352

Re: How to create folder at UNIX in SAS program?

SAS doesn't have any special code to create a directory.  Instead, it lets you issue a Unix command.  For example, within a SAS program you could code:

 

%sysexec cd /home/A123456ABC;

%sysexec mkdir My_Reports_test1;

 

I can't test it right now, but you should test it when the program you submit is in your home folder, as well as when the program is in some other folder.

View solution in original post


All Replies
Solution
‎04-28-2017 02:01 PM
Super User
Posts: 5,352

Re: How to create folder at UNIX in SAS program?

SAS doesn't have any special code to create a directory.  Instead, it lets you issue a Unix command.  For example, within a SAS program you could code:

 

%sysexec cd /home/A123456ABC;

%sysexec mkdir My_Reports_test1;

 

I can't test it right now, but you should test it when the program you submit is in your home folder, as well as when the program is in some other folder.

Regular Contributor
Posts: 230

Re: How to create folder at UNIX in SAS program?

[ Edited ]

How to embed the unix command into SAS code? I want the SAS code be executed automation include creating new folder step.

Super User
Posts: 5,352

Re: How to create folder at UNIX in SAS program?

%sysexec is the SAS code.  It doesn't need to be embedded.  Just save it as a .sas file and run it.

Frequent Contributor
Posts: 97

Re: How to create folder at UNIX in SAS program?

Not strictly true. This can also be useful if you don't have xcmd permissions:

 

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002986745.htm

 

Super User
Posts: 9,854

Re: How to create folder at UNIX in SAS program?

Check function  DCREATE() .

☑ This topic is solved.

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

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