BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Magdalena318
Calcite | Level 5

Dear community,

 

I'm trying to copy files (any, not only SAS datasets) with fcopy function, particularly, in the following way:

/* to find the corresponding logical record length for a file */

data _null_;

   infile "&source_file" lrecl=1073741823 length=rlen end=last;

   input;

   retain lrecl;

   lrecl=max(lrecl, rlen);

   if last then call symputx('rlen', lrecl);

run;

 

filename in "&source_file" lrecl=&rlen;

filename out "&dest_file" lrecl=&rlen;

 

data _null_;

   length msg $ 384;

   rc=fcopy('in', 'out');

   if rc=0

   then put 'Copied SRC to DEST.';

   else do;

      msg=sysmsg();

      putrc= msg=;

   end;

run;

 

I have also tried omitting the first data step and using lrecl=1073741823 for all files but the same result follows, which is the destination file has a slightly different size than the source file. Just in case I am comparing the sizes using the following code:

 

   %let rc=%sysfunc(filename(insize, &source_file);

   %let rc=%sysfunc(filename(outsize, &dest_file);

 

   %let fidin=%sysfunc(fopen(&insize));

   %let fidout=%sysfunc(fopen(&outsize));

 

   %let bytes_source=%sysfunc(finfo(&fidin,File Size (bytes)));

   %let bytes_dest=%sysfunc(finfo(&fidout,File Size (bytes)));

 

   %put bytes_source= &bytes_source bytes_dest= &bytes_dest;

 

I don't get any error messages though I used to get before adding the lrecl option to the filename statement because the length of the logical record of the files I'm transferring often exceed the standard length of the option (32 767) but I've found out in one of related posts here that lrecl actually can take values up to 1GB. 

I am using SAS EG 9.4 on a Unix server so I can't access admin options.

 

Thank you in advance!

 

1 ACCEPTED SOLUTION

Accepted Solutions
AllanBowe
Barite | Level 11

 As per this handy article, if you use RECFM=N then LRECL shouldn't be an issue

There's also the "old fashioned" approach of moving byte by byte:  https://core.sasjs.io/mp__binarycopy_8sas_source.html

/Allan
MacroCore library for app developers
Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs

View solution in original post

3 REPLIES 3
AllanBowe
Barite | Level 11

 As per this handy article, if you use RECFM=N then LRECL shouldn't be an issue

There's also the "old fashioned" approach of moving byte by byte:  https://core.sasjs.io/mp__binarycopy_8sas_source.html

/Allan
MacroCore library for app developers
Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
Magdalena318
Calcite | Level 5
Seems like the RECFM=N actually fixed it. Thank you very much!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1398 views
  • 0 likes
  • 3 in conversation