BookmarkSubscribeRSS Feed
ambadi007
Quartz | Level 8

Dear Experts ,

 

I am in a need of an automation of the file folder path , The exporting file should be taken and placed in the folder and folder name should be todays date ,which should automatically identified . Could any one help on this . I tried with the attached macro  but it is not working

%let td_dt=today(); 

data _NULL; 
call symput ('Folder_dt',put(&td_dt, YYMMDDd10.)); 

run; 

%put &Folder_dt; 

 

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

What "exporting file"?  All you have shown is a macro variable creation (from a already existing function!!) and a put.  If you want to write to a file with the date in the filename or in the path:

/* Folder */

ods rtf file="c:/temp/%sysfunc(today(),yymmdd10.)/yourfile.rtf";

/* Filename */

ods rtf file="c:/temp/somewhere/file_%sysfunc(today(),yymmdd10.).rtf";

No need to do all the macro parts.  

PaigeMiller
Diamond | Level 26

How about this?

 

data _NULL; 
    call symput ('Folder_dt',put(today(), YYMMDDd10.)); 
run; 
%put &=folder_dt;
--
Paige Miller
BrunoMueller
SAS Super FREQ

See sample code below. It uses the macro facility to create the foldername. Then a LIBNAME statement together with the DLCREATEDIR system option is used to create the actual folder on the filesystem.

 

options dlcreatedir;

%let todayFolderName = %sysfunc( today() , yymmddd10.);

libname _cdir "c:\temp\&todayFolderName";
libname _cdir clear;

Depending on your SAS version have a look at the DCREATE function as well.

 

 

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
  • 1043 views
  • 0 likes
  • 4 in conversation