Hi,
I have requirement to create Archive of Older Files and the Current folder has SAS/log/lst/rtf/pdf/png files created with Datetime Stamp.
Now,I need to move all the files from the current folder to the Archive and just retain only the recent TimeStamped Set of files in Current.
I am planning to route all SAS Created Files to Current folder and in the same code writing the below Piece of Macro to move the previously created files.
%macro test;
%sysexec %str(mkdir ./Archive;mv ./Current/* ./Archive);
%mend test;
%test;
problem Area:
But after "/*" ,SAS Code is getting commented..
So,I am not able to select all the files from the Current Folder.
Can you please help me out to fix this approach?
Thanks in advance!
Regards,
Abi
Use the filename pipe method, and put the command in quotes:
filename oscmd "mkdir ./Archive;mv ./Current/* ./Archive 2>&1";
data _null_;
infile oscmd;
input;
put _infile_;
run;
You won't have a problem with seeming SAS syntax (eg comments) inside the command string, and all responses from the system will end up in the SAS log.
That's Great!
Thanks much Reeza..I can copy individual file..
But I am not able to copy all the files using below macro..Can you please help??
%let path=/sdsbai/common/SAS_new/Final_Testing;
%macro test;
%sysexec "mv &path/Test_case1/* &path/Archive";
%mend test;
%test;
Thanks!
Abi
Use the filename pipe method, and put the command in quotes:
filename oscmd "mkdir ./Archive;mv ./Current/* ./Archive 2>&1";
data _null_;
infile oscmd;
input;
put _infile_;
run;
You won't have a problem with seeming SAS syntax (eg comments) inside the command string, and all responses from the system will end up in the SAS log.
Thanks all!!
Much appreciated Solutions 🙂
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.