BookmarkSubscribeRSS Feed
rajredy7172012
Calcite | Level 5

Hi:

I would like to copy some excel files from one location to another in SAS. Can't find the best solution out there. Let's say in the source folder, I have 5 files and I want to only copy 3 files to the destination folder. The filenames are random. What is the best solution? I tried Fcopy but didn't work.

Thanks,

Rajesh.

5 REPLIES 5
Reeza
Super User

What do you mean by FCOPY didn't work? It's the solution that should work regardless of OS

Please post your code/log. 

 

To do this, you require access to both locations from SAS/SAS Server and you need to know which files. 

You can select randomly but that's a very unusual requirement, usually it's most recent/latest or specific ones. 

Other options are Pipe or X commands, do you know if you have XCMD option enabled?

 

 

 

rajredy7172012
Calcite | Level 5

/* these IN and OUT filerefs can point to anything */
filename in 'Y:\Raw_DS\Neratinib\5201_v6\Output\Programmed Listings new url\L1.xlsx';
filename out 'M:\L1.xlsx';

/* copy the file byte-for-byte */
data _null_;
length filein 8 fileid 8;
filein = fopen('in','I',1,'B');
fileid = fopen('out','O',1,'B');
rec = '20'x;
do while(fread(filein)=0);
rc = fget(filein,rec,1);
rc = fput(fileid, rec);
rc =fwrite(fileid);
end;
rc = fclose(filein);
rc = fclose(fileid);
run;

filename in clear;

filename out clear;

Reeza
Super User
What's the purpose of this code? Is this what you tried? I don't see FCOPY being sued anywhere....
andreas_lds
Jade | Level 19

If xmcd is enabled and no plans exist to migrate your sas-environment to another os, use it.

Kurt_Bremser
Super User

Please post the code you used.

Do you want to randomly select 3 files from the 5 that are there, or is it just that the number of files present is arbitrary, and you need to select according to a rule?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 888 views
  • 0 likes
  • 4 in conversation