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 🙂
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.