DATA Step, Macro, Functions and more

How to move disk files around

Accepted Solution Solved
Reply
Frequent Contributor
Frequent Contributor
Posts: 78
Accepted Solution

How to move disk files around

[ Edited ]

I have multiple txt files in dir D:\in and would like to transfer all the txt files to dir D:\out

 

Is there SAS command can copy the mutiple txt files from one directory to another?

 

Thanks.


Accepted Solutions
Solution
‎03-14-2018 11:13 PM
Super User
Super User
Posts: 9,200

Re: SAS query

The simplest method is to use the OS commands, for example on windows:

data _null_;
  x 'copy "d:/in/*.txt" "d:/out"';
run;

You could also use a datastep to read in the files (infile) and write them out again (file).

You could use fcopy function.

Try having a go and coming back with questions.

View solution in original post


All Replies
Solution
‎03-14-2018 11:13 PM
Super User
Super User
Posts: 9,200

Re: SAS query

The simplest method is to use the OS commands, for example on windows:

data _null_;
  x 'copy "d:/in/*.txt" "d:/out"';
run;

You could also use a datastep to read in the files (infile) and write them out again (file).

You could use fcopy function.

Try having a go and coming back with questions.

Regular Contributor
Posts: 153

Re: SAS query

Hi,

 

well I personally use robocopy to also recreate the structure of the subfolders:

DATA _NULL_;
  x 'ROBOCOPY "D:\in" "D:\out" *.txt /MIR';
RUN;

It performs the job without carrying about the existence of the 'out' Folder.

 

________________________

- Cheers -

Super User
Posts: 22,844

Re: How to move disk files around

FCOPY() function as of SAS 9.4+

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 100 views
  • 0 likes
  • 4 in conversation