BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Abinaya
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

5 REPLIES 5
Reeza
Super User
Instead of %STR() try using quotation marks which will mask the asterisk (*) which is causing the issue.

Abinaya
Calcite | Level 5

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

 

 

Reeza
Super User
mv is a system command that moves files from one directory to another, guessing Unix/Linux. %SYSEXEC passes the command to the operating system to execute.

So you need to find the correct unix command, but that's not a question I can answer - I google unix commands every time I need them :).
Kurt_Bremser
Super User

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.

Abinaya
Calcite | Level 5

Thanks all!!

Much appreciated Solutions 🙂

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 5 replies
  • 10271 views
  • 1 like
  • 3 in conversation