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
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

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
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

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!

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
  • 3 replies
  • 578 views
  • 0 likes
  • 3 in conversation