Help using Base SAS procedures

How to use sas to copy a text files

Reply
Super Contributor
Posts: 371

How to use sas to copy a text files

Please, I have a text files( f1_g.txt, f2_m.txt, .  fm_g.txt  ..fn_y.txt)  in the directory W1 and I want to copy some of them in the directory W2.

1- I want only to copy some of them (f1_g.txt, fm_g.txt....) from the directory W1 to the directory W2

2- I will make a copy from Unix to windows and from also windows to unix.

3- I do not want to use the x command( exemple : x cp f1 /w2). I want to use a sas program for all os.

Thank you.

Super User
Posts: 19,858

Re: How to use sas to copy a text files

1. Obtain a list of files in the directory

http://www.wuss.org/proceedings12/55.pdf

1b. Filter based on criteria required - unspecified in question

2. Copy the file using the method specified here - byte by byte copying.

http://blogs.sas.com/content/sasdummy/2011/06/17/how-to-use-sas-data-step-to-copy-a-file-from-anywhe...

Super Contributor
Posts: 371

Re: How to use sas to copy a text files

Thank you for your answer

Super User
Posts: 19,858

Re: How to use sas to copy a text files

There is also the FCOPY function in SAS 9.4 at least. Not sure about earlier versions.

PROC Star
Posts: 1,167

Re: How to use sas to copy a text files

Generally you can't access Windows and Unix directories from the same computer, unless some arrangement has been made using something like Samba to mount the dissimilar type. Has this been done in your case?

Tom

Super Contributor
Posts: 371

Re: How to use sas to copy a text files

Thank you for your message.

Is this been done in my case? non

Super User
Posts: 7,854

Re: How to use sas to copy a text files

To copy files between systems when there is no mapped-drive connection requires SAS (with SAS/CONNECT licensed) to be present on both systems.

If you don't have that, your only other option is using a file copy method like SFTP, which requires external commands with the X statement or system() function or call system() subroutine.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 7,987

Re: How to use sas to copy a text files

I would also suggest this sounds more like an FTP request.  TBH if your not sure I would contact your IT support and have them setup file transfers/shared areas for you as you can run into all kinds of difficulties. 

Ask a Question
Discussion stats
  • 7 replies
  • 576 views
  • 11 likes
  • 5 in conversation