SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SASPhile
Quartz | Level 8

I have to copy 14K files from one directory to another. when using the below code, the cmd window opens 14K times and this is interrupting from doing further work. 

1. How to make it work with out interrupting the user?

2. If the files are already presnt in destination folder, either delete them or overwrite them. The following code popups cmd window to manually key in the response by the user.

How to achieve above two conditions?

 

options noxwait noxsync;
data _null_;
%do i=1 %to &count.;
%sysExec xcopy "&landing_zone.\&&memname&i" "&dest.\";
%end;
run;
proc printto;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You're passing a system command and need to find the relevant system option. 

 

For XCOPY that appears to be /Y

 

See the Microsoft documentation, here:

https://support.microsoft.com/en-us/help/240268/copy,-xcopy,-and-move-overwrite-functionality-change...

View solution in original post

7 REPLIES 7
jdwaterman91
Obsidian | Level 7

Have you tried specifying the XMIN Option?

SASPhile
Quartz | Level 8

No ,havent tried

LinusH
Tourmaline | Level 20
Can't you use /s and omit the looping?
Data never sleeps
SASPhile
Quartz | Level 8

never tried that.

Looping lets me choose only the files of interest. I'm not sure how /s works.

 

if there are

abc.txt

pqr.txt

xyz.txt

and I want to choose only pqr.txt and xyz.txt based on some conditions, I will pass the two file names into a macro array and loop them to move to a new folder.

Imagine i had to move 14k files out of 50k

Reeza
Super User

You're passing a system command and need to find the relevant system option. 

 

For XCOPY that appears to be /Y

 

See the Microsoft documentation, here:

https://support.microsoft.com/en-us/help/240268/copy,-xcopy,-and-move-overwrite-functionality-change...

SASPhile
Quartz | Level 8
When the number of file sizes increases, I'm getting an error.
Xcopy.exe Application error popup.
Reeza
Super User

Like I mentioned you're using Windows command, SAS is just passing it to the system. Figure out what works in the system and that's a Windows question, not a SAS question. 

 

Then incorporate that solution here. 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 8178 views
  • 3 likes
  • 4 in conversation