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.
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?
/* 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;
If xmcd is enabled and no plans exist to migrate your sas-environment to another os, use it.
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?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.