BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
djbateman
Lapis Lazuli | Level 10

Suppose I have a library of SAS datasets that are updated regularly, and I use those datasets to create new analysis datasets for each update.  I want to store those new analysis datasets in archived folders.  Is it possible to have SAS create a folder in my code, or do I have to manually create the folder and then tell SAS where to store the data?

For example, let's say that I have my base datasets stored in C:\Studies\DrugA\Protocol1\Data.  And suppose that I am outputting my analysis data into the following directory: C:\Studies\DrugA\Protocol1\AnalysisDatasets.  However, I want to archive them, so I will have a new subfolder for each date I run the data, so I might have the following folders:

C:\Studies\DrugA\Protocol1\AnalysisDatasets\2013-01-01

C:\Studies\DrugA\Protocol1\AnalysisDatasets\2013-02-10

C:\Studies\DrugA\Protocol1\AnalysisDatasets\2013-02-17

C:\Studies\DrugA\Protocol1\AnalysisDatasets\2013-04-11

etc.

Is there a way to set up SAS code to create a folder based on the date the program is run, or do I have to manually create the folder and then change the LIBNAME statement in my code?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Yes, Use the dcreate() function with a macro variable for the date.

SAS(R) 9.3 Functions and CALL Routines: Reference

View solution in original post

3 REPLIES 3
OS2Rules
Obsidian | Level 7

Hi:

I think it can, but we just run a DOS command to do it:  Here is a sample doing a file move.....

  %let cmd = MOVE "&prefix.\From\File.txt" "&prefix.\Archive\File.txt";

  data _null_;

  option noxwait;

  X &movecmd;

  run;

Reeza
Super User

Yes, Use the dcreate() function with a macro variable for the date.

SAS(R) 9.3 Functions and CALL Routines: Reference

jakarman
Barite | Level 11

Live can be that easy when it is done automatic

SAS trick: get the LIBNAME statement to create folders for you - The SAS Dummy

---->-- ja karman --<-----

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 9217 views
  • 3 likes
  • 4 in conversation