BookmarkSubscribeRSS Feed
mmea
Quartz | Level 8

Hi

 

I have to send out an automail with a file from a folder from my computer.

the file will have this name : 

test-test-covid19-DDMMYYYY-xxxx

where XXXX will be NEW numbers/letters everyday - how can I make a macro that will generate the new file name with the new XXXX everyday without me manually put it in

1 REPLY 1
japelin
Rhodochrosite | Level 12

Before you can create a macro program, you need to create a program that works manually.

Have you already created it? If you have a program, we can advise you on how to make a macro.

 

Also, is XXXX a sequential number?

This can be done by recording the numbers in an external file or permanent data set.

Each time you run the program, you can read the number and overwrite it with +1.


For example, the following program will store a sequential number starting from 0001 in the macro variable "XXXX" every time it is executed.

%if %sysfunc(exist(lib.covid))=0 %then %do;
  data lib.covid;
    cnt=0;
  run;
%end; 

data lib.covid;
  set lib.covid;
  cnt=cnt+1;
  call symputx('XXXX',put(cnt,z4.));
run;

 

The last step is to execute the program in batches.

If you are using Windows, you can register the following command in the task scheduler.

"C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -sysin "C:\temp\yourprogram.sas"

-sysin is the command to batch submit.

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 375 views
  • 0 likes
  • 2 in conversation