'Copy All Files and Directories & Subdirectories in SAS

I used the follwoing statement to copy over files from one folder to another... but it does not copy over the subdirectory (and the files and folders under that subdirectory)

%sysExec copy "&driv.\&path1\*"  "&driv.\&path2";

Any Solutions?



Solution 1:[1]

I don't think this is a SAS question. This would depend on your enviroment.

If you are on Windows, try xcopy

If you working in another environment, post additional info

Solution 2:[2]

I usually use a FILENAME PIPE for this, and then execute through a data step. The standard output is then captured in the data step. I've not got SAS available at the moment, but it would look something like this:

filename mycopy pipe """xcopy "&driv.\&path1\*.*" "&driv.\&path2\""";

data copydir;
  infile mycopy;
  input;
  stdout=_infile_;
run;

You can check the data set's STDOUT variable for feedback on what happened.

If you're still running into trouble, then test the command you're running from the command line first and then transfer to your SAS code.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jay Corbett
Solution 2 DavB