BookmarkSubscribeRSS Feed
Pavan4
Calcite | Level 5

1)I would need create one directory like 24042018(directory) by using X command

for example : 'x mkdir /data/file/data_folder';

when ever we run that code it will create current datefolder

 

2)Directories should maintain only week folders remaining folder should delete through sas program

 

Really appreciate your help on this

 

3 REPLIES 3
Reeza
Super User

Why XCMD? Can you use DCREATE()? Or the LIBNAME trick with the DLCREATEDIR option enabled.

https://blogs.sas.com/content/sasdummy/2013/07/02/use-dlcreatedir-to-create-folders/

 

There's also FDELETE() to delete the folders you don't want.

 

 

Pavan4
Calcite | Level 5

Hi Thanks for your reply but we are using unix environment .All the folders are in unix boxes.that is why I am using X commands

but I would need create directory with current dateformat for example the if I execute the sas code today it should create folder like 24042018 in some directory

Really appreciate your help 

Reeza
Super User

Not sure why you still can't use DCREATE() or LIBNAME. This is the idea below. 

 

data _null_;

path_to_folder = '/folders/myfolders/';
date_char = put(today, yymmdd10.);
folder_name = catx("_", 'folder', date_char);

y = dcreate(folder_name, path_to_folder);

run;


To check for the existence of the other folder you can use FEXIST and then FDELETE. You didn't specify how the naming is managed but it should be relatively straightforward if you have a structured process. 

 


@Pavan4 wrote:

Hi Thanks for your reply but we are using unix environment .All the folders are in unix boxes.that is why I am using X commands

but I would need create directory with current dateformat for example the if I execute the sas code today it should create folder like 24042018 in some directory

Really appreciate your help 


 If you have to use X commands, you need to find the Unix commands which is best done on a unix forum, and then you pass them to the system using %SYSEXEC, CALL SYSTEM, or X statements. 

 

In that case, I'd test the commands on the unix side first as well and then move the commands back to SAS after they're fully tested, otherwise you have more room for error.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 3 replies
  • 815 views
  • 1 like
  • 2 in conversation